鱼C论坛

 找回密码
 立即注册
查看: 2309|回复: 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的代码 ...
想知道小甲鱼最近在做啥?请访问 -> 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;ˇ) 想弄贪吃蛇 ......说难听点就是痴心妄想说好听点就是不自量力 真的冒泡排序 迭代 不是很难的吧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2014-2-10 22:47:23 | 显示全部楼层
顺便说下 graphics.h 这个要在VC下用 说能打补丁使用我也是听说反正我是没见到过那个神奇的补丁
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

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

使用道具 举报

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

{:7_176:}好吧 但是贪吃蛇VC++6.0下 确实...... 链表的话倒是可以
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

struct student
{
        long int num;
        float score;
        struct student *next;
};
int n;
char ch;
int main()
{
        struct student *head,head_2;
        int num,i;
        float score;
        printf("请先建立一个链表!(要结束请在number处输入0)\n");
        head = create();
s:        setbuf(stdin,NULL);
        printf("---------------------------------------------------------\n");
        printf("请选择要的操作:\n");
        printf("1.打印记录     ");
        printf("2.插入记录     ");
        printf("3.删除记录     \n");
        printf("4.更改记录     ");
        printf("5.清除记录     ");
        printf("6.退出程序     \n");
        printf("---------------------------------------------------------\n");
        scanf("%d",&i);
        switch(i)//根据用户输入的不同数字来执行不同的代码
        {
        case 1:
                print(head);
                goto s;
                break;
        case 2:
s4:            setbuf(stdin,NULL);
                printf("what number are you want to insert:");
                scanf("%d",&head_2.num);
                        while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s4;
                        }
                }
s5:                setbuf(stdin,NULL);
                printf("what score are you want to insert:");
                scanf("%f",&head_2.score );
                        while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s5;
                        }
                }
                head = insert(head,&head_2);
                goto s;
                break;
        case 3:
s6:         setbuf(stdin,NULL);
                printf("please putinto the number you want to delete:");
                scanf("%ld",&num);
                        while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s6;
                        }
                }
                head = del(head,num);
                goto s;
                break;
        case 4:
s7:                setbuf(stdin,NULL);
                printf("Please putinto the number you want to change:");
                scanf("%d",&num);
                        while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s7;
                        }
                }
s8:                setbuf(stdin,NULL);
                printf("Please putinto the score you want to save:");
                scanf("%f",&score);
                        while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s8;
                        }
                }
                change(head,num,score);
                break;
        case 5:
                head=clear(head);
                break;
        case 6:
                return 0;
                break;
        default:
                printf("对不起,你的输入有误,请重新输入!");
                goto s;
                break;
        }
        
        goto s;
}
struct student *create()
{
        struct student *head;
        struct student *p1,*p2;
s:        setbuf(stdin,NULL);
        head = NULL;
        p1 = p2 = (struct student *)malloc(LEN);
        printf("Please purinto student's munber:");
        scanf("%ld",&p1->num );
                while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s;
                        }
                }
s1:        printf("Please putinto student's score:");
        setbuf(stdin,NULL);
        scanf("%f",&p1->score );
        while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s1;
                        }
                }
        n = 0;
        while(p1->num )
        {
        n++;
        if(n==1)
        {
                head = p1;
        }
        else
        {
                p2->next =p1;
        }
        p2 = p1;
        p1 = (struct student *)malloc(LEN);
s2:        setbuf(stdin,NULL);
        printf("Please purinto student's munber:");
        scanf("%ld",&p1->num );
        while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s2;
                        }
                }
        if(p1->num ==0)
        {
                goto e;
        }
s3:        setbuf(stdin,NULL);
        printf("Please putinto student's score:");
        scanf("%f",&p1->score );
                while((ch=getchar())!='\n')
                {
                        if((ch>=48&&ch<=57)||ch==46)
                        {
                                ;
                        }
                        else
                        {
                                printf("你的输入有误!\n");
                                goto s3;
                        }
                }
        }
e:        p2->next =NULL;
        return head;
}

void print(struct student *head)
{
        struct student *p;
        p = head;
        printf("共有%d条记录:\n",n);
        if(head)
        {
                do
                {
                        printf("%ld号学生的成绩是:%f\n",p->num,p->score);
                        p = p->next ;
                }while(p);
        }
}

struct student *del(struct student *head,int num)
{
        struct student *p1,*p2;
        if(NULL == head)
        {
                printf("The List is NULL!\n");
                goto END;
        }
        
        
        p1 = head;
        while(p1->num !=num&&p1->next !=NULL)
        {
                p2 = p1;
                p1 = p1 ->next ;
        }
        
        if(num == p1->num )
        {
                if(p1 == head)
                {
                        head = p1 ->next ;
                        printf("Delete NO.%d succeed!\n",num);
                        n--;
                }
                else
                {
                        p2->next =p1->next ;
                        printf("Delete NO.%d succeed!\n",num);
                        n--;
                }
        }
        else
        {
                printf("NO.%d not been found!\n",num);
        }
END:    
        return head;
}

struct student *insert(struct student *head,struct student *head_2)
{
        struct student *p0,*p1,*p2;
        p0 = head_2;
        p1 = head;
        if(p1==NULL)
        {
                head = p0;
                p0->next =NULL;
        }
        else
        {
                while(p0->num >p1->num && p1->next !=NULL)
                {
                        p2 = p1;
                        p1 = p1 ->next ;
                }
                if(p0->num <= p1->num)
                {
                        if(p1 == head)
                        {
                                head = p0;
                        }
                        else
                        {
                                p2->next =p0;
                        }
                        p0->next =p1;
                }
                else
                {
                        p1->next =p0;
                        p0->next =NULL;
                }
        }
        n++;
e:        return head;
}

struct student *clear(struct student *head)
{
        head = NULL;
        n=0;
        printf("以清除全部记录!\n");
        return head;
}

void change(struct student *head,int num,float score)
{
        struct student *p1,*p2;
        if(head == NULL)
        {
                printf("This is a NULL!\n");
                goto end_2;
        }
        p1 = head;
        while(p1->num !=num&&p1->next !=NULL)
        {
                p2 = p1;
                p1=p1->next ;
        }
        if(p1->num ==num)
        {
                p1->score = score;
        }
        else
        {
                printf("NO.%d not been found!",num);
        }
end_2:
        printf("");
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2014-2-11 12:46:29 | 显示全部楼层
这个链表是我自己写的可能会有错误 表见怪啊
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2014-2-11 13:06:00 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

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


想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

你这个是linux下的代码吧 在windows下不能的
都说了 要么用turbo C 要么去linux 自己选吧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-10 17:11

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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