| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 608 人关注过本帖
标题:看看我这程序的毛病,大哥大姐们帮帮忙
只看楼主 加入收藏
taopwen
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-8-31
收藏
 问题点数:0 回复次数:3 
看看我这程序的毛病,大哥大姐们帮帮忙

看看我这程序的毛病,大哥大姐们帮帮忙 #include<stdio.h> #include<string.h> #include<malloc.h> #define NULL 0 #define LEN sizeof(struct student) struct student {long int num; char nam; int Escore; int Mscore; int Cscore; int Ascore; struct student *next; };

struct student *input(void) {struct student *p1,*p2,*head; int n=0; printf("Enter the heo recores.\nAnd if you want to exit:please enter 0!\n"); p1=p2=(struct student *)mallocl(LEN); scanf("%ld %c %d %d %d\n",&p1->num,&p1->nam,&p1->Escore,&p1->Cscore,&p1->Mscore); head=NULL; while(p1->num!=0) {n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct student *)malloc(LEN); scanf("%ld %s %d %d %d \n",&p1->num,&p1->nam,&p1->Escore,&p1->Cscore,&p1->Mscore); p1->Ascore=p1->Escore+p1->Mscore+p1->Cscore; return head; } }

void output(struct student *head) {char k; struct student *p1,*p2; clrscr(); 1ab: printf("If you want exit,enter = !\n"); printf(" else press Enter \n"); getchar(); if (strcmp(k,"="==0)) return; if (strcmp(k,"\n"==0)) {p1=p2=head; p1->next=p1; if(head=NULL) {printf("It is empty!\n"); goto 1ab;} } else {printf("number name English Cmputer Math Total\n"); while (p1->next!=NULL) printf("%ld %c %d %d %d %d\n",p1->num,p1->nam,p1->Escore,p1->Cscore,p1->Mscore,p1->Ascore);

}

}

void find(struct student *head) {int find; struct student *p1,*p2; int i; 2ab: printf("Enter the number which you want to find.If you want exit,enter 0 !\n"); scanf("%d",&find); if(find==0) return; else for(p1=p2=head;p1->next!=NULL;p1++) if(p1->num==find) {printf("Numer Name English Compruter Math Average\n"); printf("%ld %c %d %d %d %d\n",p1->num,p1->nam,p1->Escore,p1->Cscore,p1->Mscore,p1->Ascore); } if(p1->num!=find) {printf("There is no the student which you want!\n"); goto 2ab; }

void inster(struct student *head) {struct student *stu,*p2,*p0,*p1; printf("Input the student infermation!\n"); printf("Number Name English Computer Math\n"); scanf("%ld %c %d %d %d\n",&stu->num,&stu->nam,&stu->Escore,&stu->Csore,&stu->Mscore); stu->Ascore=stu->Escore+stu->Cscore+stu->Mscore); 3ab:printf("which student do you want behind?\nAnd if you want exit,enter 0 !\n"); scanf("%ld\n",&p0->num); if(p0->num==0) return; else {p2=p1=head; if(head==NULL) {head=stu; stu->next=NULL; } else {while((p2->num!=p0->num)&&(p1->num!=NULL)) {p2=p1=head; p1=p1->next; } if(p2->num==p0->num) {p2->next=stu->num; stu->next=p1->num; } else {printf("There is no the student %ld\n",p0->num); goto 3ab; } } }

void delete (struct student *head) {struct student *p1,*p2,*p0; 4ab:printf("Enter the number which you want to delete.Ifyou want exit,enter 0 !\n"0; scanf("%ld\n",&p0->num); if(p0->num==0) return; while((p2->num!=p0->num)&&(p1->num!=NULL)) {p1=p2=head; p1=p1->next; } if(p2->num!=p0->num)&&(head!=NULL) {printf("There is no the record which you want!\n"); goto 4ab; } else if(head==NULL) {printf("The school report is empty!\n"); goto 4ab; } else if(p2->num==p0->num) {p2->next=p0->next; ("The student had been deleted!\n"); goto 4ab; } }

main() {long int *head; int a; clrscr(); printf("print a number from 1 to 6 !\n"); scanf("%d\n",&a); abc:switch(a) {case"1":head=input();break; case"2":output(head);break; case"3":find(head);break; case"4":insert(head);break; case"5":delete(head);break; case"6":goto abc;break; default:printf("Error common!\n");break;

} }

搜索更多相关主题的帖子: 大哥大姐 student int struct 毛病 
2005-08-31 16:13
workhard
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2004-11-17
收藏
得分:0 
你怎么没有说明有什么问题?

2005-08-31 16:47
taopwen
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-8-31
收藏
得分:0 
用链表建立一个学生成绩表

用链表建立一个学生成绩表

有学号、姓名、数学成绩、计算机成绩、英语成绩、总分6个字段,可以通过学号来检索某学生成绩,可以在链表的指定位置插入、删除某学生记录。

2005-09-01 09:05
ychshou
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-9-3
收藏
得分:0 
2005-09-03 21:19
快速回复:看看我这程序的毛病,大哥大姐们帮帮忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.055668 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved