鱼C论坛

 找回密码
 立即注册
查看: 3401|回复: 9

C语言学完后想到的见到的杂七杂八的问题,求解决

[复制链接]
发表于 2014-2-10 20:41:21 | 显示全部楼层 |阅读模式
30鱼币
1: typedef  这个就是 重命名,带类型的

但是这样子是什么意思呢?
typedef  struct  student
{
      xxxxxxxx;
      xxxxxxxx;
}b;
我想不明白,求解释,也可能这个想法就是错误的,、
2:  贪吃蛇问题,
graphics.h  这个库,  我看到的贪吃蛇都是有这个库的 ,我学的时候用的就是 VC+6.0 ,编译之后提示 错误, 没有这个库,求好的解决办法,或 求 谁把这个库换成别的库 只要VC+6.0 的能运行都可以, 就是把源代码改成VC+6.0能运行的,给我一份,谢谢了,  ,,  这里我就想说一下  甲鱼老师了, C语言都讲了65课,也不差讲那几课了·,  最后起码  带我们写个 贪吃蛇把,,至少让我们 菜鸟也有一些成就感,, ()
3: C语言 直接就 调用  DOS 了 ,这个 在哪里学, 我想看一下,
就是 别人在写的 贪吃蛇里面  上来就是          system("mode con cols=100 lines=30");  的,很郁闷,百度了一下就是DOS 调用把好像,  
4:   图.png 图中的C++ 的那个是不是 不属于C语言的范畴了。平常没见过,
5:  求一份没有 graphics.h  的贪吃蛇代码,能VC+6.0 用的    最好能用注释, 本人不会数据结构和算法,只会链表这个排序冒泡,迭代等等,太复杂了 就不用了 ,

大家能帮忙回答几个就回答几个,最佳答案会给 回答  5,和回复其他任意一个问题的,

最佳答案

查看完整内容

1:貌似只说了这种结构的名称叫b 2:graphics.h这个头文件vc++6.0本身是没有的就算你下载了也没用他是不兼容的 必须要打补丁 3:直接调用DOS很简单啊加上头文件#include 然后直接写system("DOS命令");即可 4:哪个??你是指cmd.cpp这个是C++的源文件啊all.h看样子不是本身自带的是自己加的类似于易语言的模块 比如常用的printf就是在头文件stdio.h中定义好的 5.基本上没有只有turboC和linux的 VC只能打补丁去用turboC的代码 ...
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-2-10 20:41:22 | 显示全部楼层
1:貌似只说了这种结构的名称叫b
2:graphics.h这个头文件vc++6.0本身是没有的就算你下载了也没用他是不兼容的 必须要打补丁
3:直接调用DOS很简单啊加上头文件#include<windows.h> 然后直接写system("DOS命令");即可
4:哪个??你是指cmd.cpp这个是C++的源文件啊all.h看样子不是本身自带的是自己加的类似于易语言的模块
比如常用的printf就是在头文件stdio.h中定义好的
5.基本上没有只有turboC和linux的 VC只能打补丁去用turboC的代码
还有你说冒泡都复杂你(ˇ&#717;ˇ) 想弄贪吃蛇 ......说难听点就是痴心妄想说好听点就是不自量力 真的冒泡排序 迭代 不是很难的吧
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-2-10 22:47:23 | 显示全部楼层
顺便说下 graphics.h 这个要在VC下用 说能打补丁使用我也是听说反正我是没见到过那个神奇的补丁
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-2-11 12:32:04 | 显示全部楼层

我说 的是我上面列举的简单算法都会, 其他的就都不会了:sweat:   真的没有C语言贪吃蛇代码吗。 帮写一个吧,我很想看看,  链接也好 , 要VC+6.0能运行就好,:handshake
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-2-11 12:45:20 | 显示全部楼层
Ъγ:_小ツ雨oο 发表于 2014-2-11 12:32
我说 的是我上面列举的简单算法都会, 其他的就都不会了   真的没有C语言贪吃蛇代码吗。 帮写一个 ...

{:7_176:}好吧 但是贪吃蛇VC++6.0下 确实...... 链表的话倒是可以
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-2-11 12:45:53 | 显示全部楼层
Ъγ:_小ツ雨oο 发表于 2014-2-11 12:32
我说 的是我上面列举的简单算法都会, 其他的就都不会了   真的没有C语言贪吃蛇代码吗。 帮写一个 ...
  1. #include<stdio.h>
  2. #include<malloc.h>
  3. #include<string.h>
  4. #define LEN sizeof(struct student)
  5. struct student *create();//创建链表
  6. struct student *del(struct student *head,int num);//删除链表中数字 (链表头指针,要删除的学号)
  7. struct student *insert(struct student *head,struct student *head_2);//网链表中加元素(链表头指针,要加的那个的)
  8. void print(struct student *head);//输出链表
  9. struct student *clear(struct student *head);//清空链表
  10. void change(struct student *head,int num,float score);//更改链表数据

  11. struct student
  12. {
  13.         long int num;
  14.         float score;
  15.         struct student *next;
  16. };
  17. int n;
  18. char ch;
  19. int main()
  20. {
  21.         struct student *head,head_2;
  22.         int num,i;
  23.         float score;
  24.         printf("请先建立一个链表!(要结束请在number处输入0)\n");
  25.         head = create();
  26. s:        setbuf(stdin,NULL);
  27.         printf("---------------------------------------------------------\n");
  28.         printf("请选择要的操作:\n");
  29.         printf("1.打印记录     ");
  30.         printf("2.插入记录     ");
  31.         printf("3.删除记录     \n");
  32.         printf("4.更改记录     ");
  33.         printf("5.清除记录     ");
  34.         printf("6.退出程序     \n");
  35.         printf("---------------------------------------------------------\n");
  36.         scanf("%d",&i);
  37.         switch(i)//根据用户输入的不同数字来执行不同的代码
  38.         {
  39.         case 1:
  40.                 print(head);
  41.                 goto s;
  42.                 break;
  43.         case 2:
  44. s4:            setbuf(stdin,NULL);
  45.                 printf("what number are you want to insert:");
  46.                 scanf("%d",&head_2.num);
  47.                         while((ch=getchar())!='\n')
  48.                 {
  49.                         if((ch>=48&&ch<=57)||ch==46)
  50.                         {
  51.                                 ;
  52.                         }
  53.                         else
  54.                         {
  55.                                 printf("你的输入有误!\n");
  56.                                 goto s4;
  57.                         }
  58.                 }
  59. s5:                setbuf(stdin,NULL);
  60.                 printf("what score are you want to insert:");
  61.                 scanf("%f",&head_2.score );
  62.                         while((ch=getchar())!='\n')
  63.                 {
  64.                         if((ch>=48&&ch<=57)||ch==46)
  65.                         {
  66.                                 ;
  67.                         }
  68.                         else
  69.                         {
  70.                                 printf("你的输入有误!\n");
  71.                                 goto s5;
  72.                         }
  73.                 }
  74.                 head = insert(head,&head_2);
  75.                 goto s;
  76.                 break;
  77.         case 3:
  78. s6:         setbuf(stdin,NULL);
  79.                 printf("please putinto the number you want to delete:");
  80.                 scanf("%ld",&num);
  81.                         while((ch=getchar())!='\n')
  82.                 {
  83.                         if((ch>=48&&ch<=57)||ch==46)
  84.                         {
  85.                                 ;
  86.                         }
  87.                         else
  88.                         {
  89.                                 printf("你的输入有误!\n");
  90.                                 goto s6;
  91.                         }
  92.                 }
  93.                 head = del(head,num);
  94.                 goto s;
  95.                 break;
  96.         case 4:
  97. s7:                setbuf(stdin,NULL);
  98.                 printf("Please putinto the number you want to change:");
  99.                 scanf("%d",&num);
  100.                         while((ch=getchar())!='\n')
  101.                 {
  102.                         if((ch>=48&&ch<=57)||ch==46)
  103.                         {
  104.                                 ;
  105.                         }
  106.                         else
  107.                         {
  108.                                 printf("你的输入有误!\n");
  109.                                 goto s7;
  110.                         }
  111.                 }
  112. s8:                setbuf(stdin,NULL);
  113.                 printf("Please putinto the score you want to save:");
  114.                 scanf("%f",&score);
  115.                         while((ch=getchar())!='\n')
  116.                 {
  117.                         if((ch>=48&&ch<=57)||ch==46)
  118.                         {
  119.                                 ;
  120.                         }
  121.                         else
  122.                         {
  123.                                 printf("你的输入有误!\n");
  124.                                 goto s8;
  125.                         }
  126.                 }
  127.                 change(head,num,score);
  128.                 break;
  129.         case 5:
  130.                 head=clear(head);
  131.                 break;
  132.         case 6:
  133.                 return 0;
  134.                 break;
  135.         default:
  136.                 printf("对不起,你的输入有误,请重新输入!");
  137.                 goto s;
  138.                 break;
  139.         }
  140.        
  141.         goto s;
  142. }
  143. struct student *create()
  144. {
  145.         struct student *head;
  146.         struct student *p1,*p2;
  147. s:        setbuf(stdin,NULL);
  148.         head = NULL;
  149.         p1 = p2 = (struct student *)malloc(LEN);
  150.         printf("Please purinto student's munber:");
  151.         scanf("%ld",&p1->num );
  152.                 while((ch=getchar())!='\n')
  153.                 {
  154.                         if((ch>=48&&ch<=57)||ch==46)
  155.                         {
  156.                                 ;
  157.                         }
  158.                         else
  159.                         {
  160.                                 printf("你的输入有误!\n");
  161.                                 goto s;
  162.                         }
  163.                 }
  164. s1:        printf("Please putinto student's score:");
  165.         setbuf(stdin,NULL);
  166.         scanf("%f",&p1->score );
  167.         while((ch=getchar())!='\n')
  168.                 {
  169.                         if((ch>=48&&ch<=57)||ch==46)
  170.                         {
  171.                                 ;
  172.                         }
  173.                         else
  174.                         {
  175.                                 printf("你的输入有误!\n");
  176.                                 goto s1;
  177.                         }
  178.                 }
  179.         n = 0;
  180.         while(p1->num )
  181.         {
  182.         n++;
  183.         if(n==1)
  184.         {
  185.                 head = p1;
  186.         }
  187.         else
  188.         {
  189.                 p2->next =p1;
  190.         }
  191.         p2 = p1;
  192.         p1 = (struct student *)malloc(LEN);
  193. s2:        setbuf(stdin,NULL);
  194.         printf("Please purinto student's munber:");
  195.         scanf("%ld",&p1->num );
  196.         while((ch=getchar())!='\n')
  197.                 {
  198.                         if((ch>=48&&ch<=57)||ch==46)
  199.                         {
  200.                                 ;
  201.                         }
  202.                         else
  203.                         {
  204.                                 printf("你的输入有误!\n");
  205.                                 goto s2;
  206.                         }
  207.                 }
  208.         if(p1->num ==0)
  209.         {
  210.                 goto e;
  211.         }
  212. s3:        setbuf(stdin,NULL);
  213.         printf("Please putinto student's score:");
  214.         scanf("%f",&p1->score );
  215.                 while((ch=getchar())!='\n')
  216.                 {
  217.                         if((ch>=48&&ch<=57)||ch==46)
  218.                         {
  219.                                 ;
  220.                         }
  221.                         else
  222.                         {
  223.                                 printf("你的输入有误!\n");
  224.                                 goto s3;
  225.                         }
  226.                 }
  227.         }
  228. e:        p2->next =NULL;
  229.         return head;
  230. }

  231. void print(struct student *head)
  232. {
  233.         struct student *p;
  234.         p = head;
  235.         printf("共有%d条记录:\n",n);
  236.         if(head)
  237.         {
  238.                 do
  239.                 {
  240.                         printf("%ld号学生的成绩是:%f\n",p->num,p->score);
  241.                         p = p->next ;
  242.                 }while(p);
  243.         }
  244. }

  245. struct student *del(struct student *head,int num)
  246. {
  247.         struct student *p1,*p2;
  248.         if(NULL == head)
  249.         {
  250.                 printf("The List is NULL!\n");
  251.                 goto END;
  252.         }
  253.        
  254.        
  255.         p1 = head;
  256.         while(p1->num !=num&&p1->next !=NULL)
  257.         {
  258.                 p2 = p1;
  259.                 p1 = p1 ->next ;
  260.         }
  261.        
  262.         if(num == p1->num )
  263.         {
  264.                 if(p1 == head)
  265.                 {
  266.                         head = p1 ->next ;
  267.                         printf("Delete NO.%d succeed!\n",num);
  268.                         n--;
  269.                 }
  270.                 else
  271.                 {
  272.                         p2->next =p1->next ;
  273.                         printf("Delete NO.%d succeed!\n",num);
  274.                         n--;
  275.                 }
  276.         }
  277.         else
  278.         {
  279.                 printf("NO.%d not been found!\n",num);
  280.         }
  281. END:   
  282.         return head;
  283. }

  284. struct student *insert(struct student *head,struct student *head_2)
  285. {
  286.         struct student *p0,*p1,*p2;
  287.         p0 = head_2;
  288.         p1 = head;
  289.         if(p1==NULL)
  290.         {
  291.                 head = p0;
  292.                 p0->next =NULL;
  293.         }
  294.         else
  295.         {
  296.                 while(p0->num >p1->num && p1->next !=NULL)
  297.                 {
  298.                         p2 = p1;
  299.                         p1 = p1 ->next ;
  300.                 }
  301.                 if(p0->num <= p1->num)
  302.                 {
  303.                         if(p1 == head)
  304.                         {
  305.                                 head = p0;
  306.                         }
  307.                         else
  308.                         {
  309.                                 p2->next =p0;
  310.                         }
  311.                         p0->next =p1;
  312.                 }
  313.                 else
  314.                 {
  315.                         p1->next =p0;
  316.                         p0->next =NULL;
  317.                 }
  318.         }
  319.         n++;
  320. e:        return head;
  321. }

  322. struct student *clear(struct student *head)
  323. {
  324.         head = NULL;
  325.         n=0;
  326.         printf("以清除全部记录!\n");
  327.         return head;
  328. }

  329. void change(struct student *head,int num,float score)
  330. {
  331.         struct student *p1,*p2;
  332.         if(head == NULL)
  333.         {
  334.                 printf("This is a NULL!\n");
  335.                 goto end_2;
  336.         }
  337.         p1 = head;
  338.         while(p1->num !=num&&p1->next !=NULL)
  339.         {
  340.                 p2 = p1;
  341.                 p1=p1->next ;
  342.         }
  343.         if(p1->num ==num)
  344.         {
  345.                 p1->score = score;
  346.         }
  347.         else
  348.         {
  349.                 printf("NO.%d not been found!",num);
  350.         }
  351. end_2:
  352.         printf("");
  353. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-2-11 12:46:29 | 显示全部楼层
这个链表是我自己写的可能会有错误 表见怪啊
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-2-11 13:06:00 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-2-11 17:58:33 | 显示全部楼层
牡丹花下死做鬼 发表于 2014-2-11 13:06
要贪吃蛇代码的话点我

t.png 版主,这个怎么解决,百度了 但是都没具体的答案,


小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-2-11 19:27:05 | 显示全部楼层
Ъγ:_小ツ雨oο 发表于 2014-2-11 17:58
版主,这个怎么解决,百度了 但是都没具体的答案,

你这个是linux下的代码吧 在windows下不能的
都说了 要么用turbo C 要么去linux 自己选吧
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-13 10:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表