刚翻出来的作品,有点低级,但希望能起到作用:

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<windows.h>
#define SLEEP() asm(&quot;sleep&quot;)
struct student *head;
struct student
{
 int a;
 int b;
 struct student * next;
};
int n;
void add()
{
 printf("请输入俩个你要储存的数字\n");
 struct student *p1, *p2;
 p1 = p2 = (struct student *)malloc(sizeof(struct student));
 head->next = p1;
 scanf_s("%d%d", &p2->a, &p2->b);
 while (p2->a != NULL)
 {
  n = n + 1;
  p1->next = p2;
  p1 = p2;
  p2 = (struct student *)malloc(sizeof(struct student));
  scanf_s("%d%d", &p2->a, &p2->b);
 }
 p1->next = NULL;

}
void print(struct student*head)
{
 if (head->next != NULL)
 {
  struct student *p1;
  p1 = (struct student *)malloc(sizeof(struct student));
  p1 = head->next;
  while (p1 != NULL)
  {
   printf("%d\t%d\n", p1->a, p1->b);
   p1 = p1->next;
  }
 }
 else printf("无法执行!!!");
}
void look()
{
 if (head->next != NULL)
 {
  struct student *p1;
  p1 = (struct student *)malloc(sizeof(struct student));
  p1 = head->next;
  int m = 1;
  printf("请输入你要查找的位置\n");
  int a;
  scanf_s("%d", &a);
  while (m != a)
  {
   m = m + 1;
   p1 = p1->next;
  }
  printf("%d\t%d\n", p1->a, p1->b);
 }
 else printf("无法执行!!!");
}
void gai()
{
 if (head->next!=NULL)
{
 struct student *p1;
 p1 = (struct student *)malloc(sizeof(struct student));
 p1 = head->next;
 int m = 1;
 printf("请输入你要修改的位置\n");
 int a;
 scanf_s("%d", &a);
 while (m != a)
 {
  m = m + 1;
  p1 = p1->next;
  
 }
 scanf_s("%d%d", &p1->a, &p1->b);
}
else printf("无法执行!!!");
}
void shan()
{
 if (head->next != NULL)
 {
  struct student *p1;
  p1 = (struct student *)malloc(sizeof(struct student));
  p1 = head;
  int m = 1;
  printf("请输入你要删除的位置\n");
  int a;
  scanf_s("%d", &a);
  while (m != a)
  {
   m = m + 1;
   p1 = p1->next;
  }
  p1->next = p1->next->next;
 }
 else printf("无法执行!!!");
}
void  zeng()/************************************************************************************/
{
 if (head->next!=NULL)
 { struct student *p1, *p2, *p3;
  p1 = (struct student *)malloc(sizeof(struct student));
  p1 = head->next;

while (p1->next != NULL)
  {
   printf("%d\t%d\n", p1->a, p1->b);
   p1 = p1->next;
  }
  printf("请输入你要储存的数据\n");
  p2 = p3 = (struct student *)malloc(sizeof(struct student));
  p1->next = p2;
  scanf_s("%d%d", &p3->a, &p3->b);
  while (p3->a!=0)
  {
   n = n + 1;
   p2->next = p3;
   p2 = p3;
   p3 = (struct student *)malloc(sizeof(struct student));
   scanf_s("%d%d", &p3->a, &p3->b);
  }
  p2->next = NULL;
 }
 else printf("无法执行!!!");
}
int main()/*******************************************************************************************/
{
 head = (struct student *)malloc(sizeof(struct student));
 head->next = NULL;
 n = 0;
 int a=1;
 printf("***************************************************************************************************************\n");
 printf("*                                      <<输入请按1>>                      <<输出请按2>>                       *\n");
 printf("*                                      <<增加请按3>>                      <<删除请按4>>                       *\n");
 printf("*                                      <<修改请按5>>                      <<退出请按0>>                       *\n");
 printf("请选择接下来的功能\n");
 while (a!=0)
 {
  scanf_s("%d", &a);
  switch (a)
  {
  case 0:break;
  case 1: add(); break;
  case 2: print(head); break;
  case 3: zeng(); break;
  case 4:shan(); break;
  case 5:gai(); break;
  default:printf("孩子不要玩了!!!"),Sleep(1000),system("cls"),printf("爸爸永远爱你!!\n");
  }
  if (a != 0){
   printf("请选择接下来的功能\n");
  }
 }
 printf("等待两分钟有惊喜哦!!!!\n");
 Sleep(20000);
 printf("让你等你就等,你傻了吧!!!sb\n");
 return 0;
}

c语言的学习秘籍之链表的更多相关文章

  1. c语言的学习秘籍

    c语言其实是一环套一环胡的,最开始的是变量,然后是数组,接着是结构体,接着是链表.(其他的是c语言的语法,那东西大多了就会了.) 学习时可以从程序在电脑里的内存看起,先了解变量,将多个变量连起来就是数 ...

  2. C语言范例学习03-上

    第三章 数据结构 章首:不好意思,这两天要帮家里做一些活儿.而且内容量与操作量也确实大幅提升了.所以写得很慢. 不过,从今天开始.我写的东西,许多都是之前没怎么学的了.所以速度会慢下来,同时写得也会详 ...

  3. C语言编程学习不难学,是你没找对方法!

    C语言是面向过程的,而C++是面向对象的 C和C++的区别: C是一个结构化语言,它的重点在于算法和数据结构.C程序的设计首要考虑的是如何通过一个过程,对输入(或环境条件)进行运算处理得到输出(或实现 ...

  4. C语言课程学习的总结

    C语言课程学习的总结 学习C程序这门课一年了,这是我们学的第一门专业课.在大学里,C语言不但是计算机专业的必修课程而且也是非计算机专业学习计算机基础的一门必修课程.所以作为我这个计算机专业的学生来说当 ...

  5. [转]C语言指针学习经验总结浅谈

    指针是C语言的难点和重点,但指针也是C语言的灵魂 . 这篇C语言指针学习经验总结主要是我入职以来学习C指针过程中的点滴记录.文档里面就不重复书上说得很清楚的概念性东西,只把一些说得不清楚或理解起来比较 ...

  6. C语言(函数)学习之strstr strcasestr

    C语言(函数)学习之[strstr]&[strcasestr]一.strstr函数使用[1]函数原型char*strstr(constchar*haystack,constchar*needl ...

  7. 【Go语言】学习资料

    这段时间一直在看Go语言,6月3日Apple发布了swift发现里面竟然也有许多Go语言的影子,截至现在每天都在感觉到Go语言的强大.确实值得一学 今天在这里给园友们推荐一些Go语言的学习资料 网站 ...

  8. 数据结构C语言版 有向图的十字链表存储表示和实现

    /*1wangxiaobo@163.com 数据结构C语言版 有向图的十字链表存储表示和实现 P165 编译环境:Dev-C++ 4.9.9.2 */ #include <stdio.h> ...

  9. 远离go path,弃用go get,使用go mod 进行go语言的学习

    标题说的是go语言的学习,因为我也没做过开发 文章要解决的仅仅是一个问题 当你使用go get 无论如何get不到所需的包的问题 第一步就是下载goland 新手极其推荐goland,因为直接使用gl ...

随机推荐

  1. Shell 编程基础之 [ 与 [[ 的异同

    一.简介 [ 与 test 等价,是 bash 的内部命令,GNU/linux 系统的 coreutils 软件包通常带 /usr/bin/test 和 /usr/bin/[ 命令.如果我们不用绝对路 ...

  2. 2016中国大学生程序设计竞赛 - 网络选拔赛 C. Magic boy Bi Luo with his excited tree

    Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migi ...

  3. log4php的配置

    网上关于log4php配置的文章很多,下面是我的配置,跟网上部分略有不同 (1)添加日志     1.下载log4php,到官网就可以下载到,下载后解压     我的版本是log4php_2.3.0 ...

  4. Django model字段类型清单

    转载:<Django model字段类型清单> Django 通过 models 实现数据库的创建.修改.删除等操作,本文为模型中一般常用的类型的清单,便于查询和使用: AutoField ...

  5. HDU 5833 Zhu and 772002(高斯消元)

    题意:给n个数,从n个数中抽取x(x>=1)个数,这x个数相乘为完全平方数,求一共有多少种取法,结果模1000000007. 思路:每个数可以拆成素数相乘的形式,例如: x1 2=2^1 * 3 ...

  6. Spring中Bean的作用域

    1.在Spring的早期版本中,仅有两个作用域:singleton和prototype,前者表示Bean以单例的方式存在:后者表示每次从容器中调用Bean时,都会返回一个新的实例 2.Spring 2 ...

  7. php http头设置相关信息

    HTTP 状态码 状态码用来告诉HTTP客户端,HTTP服务器是否产生了预期的Response. HTTP/1.1中定义了5类状态码, 状态码由三位数字组成,第一个数字定义了响应的类别 1XX 提示信 ...

  8. Spring boot 学习记录

    java的三种配置方式 基于xml的配置 基于注解的配置 基于java的配置 Spring boot推荐的配置方式:java配置+注解配置 一.注解 SpringBootApplication :等价 ...

  9. springMVC、https、GET调用别人提供的接口!!!

    import org.apache.http.HttpEntity; import org.apache.http.HttpHost; import org.apache.http.HttpStatu ...

  10. infinitynewtab 背景api

    http://img.infinitynewtab.com/wallpaper/527.jpg 图片   1-4050