一·不知道你用的是什么编译器,我帮你搞定了。
头文件#include "stdafx.h"必须放在第一位;清屏的函数也要头文件#include "conio.h";input 类型是int型的,main函数也要弄成int类型的。
还有char No[100];你要定义成数组撒,基本上有错的地方都帮你弄完了,完全没错误,能实现你的功能了,分给我吧,呵呵。
// 3.cpp : 定义控制台应用程序的入口点。
//#include "stdafx.h"#include "stdio.h" /*输入输出函数*/#include "string.h" /*字符串函数*/#include "malloc.h" /*动态内存分配*/#include "stdlib.h" /*杂项及内存分配函数*/#include "conio.h"typedef struct Node{char No[40];char Name[40];float Math;float Chinese;float sum;struct Node *prior;struct Node *next;}Node,*Link;Link head, s1, s2;struct Node *s;int n = 0, k = 0;void shuru(); /*函数调用声明*/void chaxun();void paixu();void xiugai();void shanchu();int main() /*主函数*/{int input;// clrscr(); /*清屏函数*/do{printf(" The inquire system for the students' scores\n ");printf("************************************************\n");printf(" 1>shuru\n "); printf(" 2>chaxun\n "); printf(" 3>paixu\n "); printf(" 4>xiugai\n "); printf(" 5>shanchu\n "); printf("************************************************\n");printf("please give me a choice:1,2,3,4,5,6\n ");scanf("%d",&input);switch(input){case 1:shuru();break;case 2:chaxun();break;case 3:paixu();break;case 4:xiugai();break;case 5:shanchu();break;default:printf("Something is wrong!\n");}}while(input);}void shuru() /*学生成绩输入*/ {int m;head = (Link)malloc(sizeof(Node));s = head;do{s->next = (Link)malloc(sizeof(Node));s = s->next;s->next = NULL;printf("Please input the No,Name,Math,Chinese\n");scanf("%s%s%f%f",s->No,s->Name,&s->Math,&s->Chinese);s->sum = s->Math+s->Chinese;n++;printf("Do you want to go on? 1 = yes,0 = no\n");scanf("%d",&m);}while(m);}void chaxun() /*学生成绩查询*/{int m;char No[100];do{s1 = head->next;printf("Please input the No\n");scanf("%s",No);while((strcmp(s1->No,No)) != 0 && (s1 != NULL)) /*比较两个字符串,大小相等时值为0*/{s1=s1->next;}printf("****No****Name****Math****Chinese*******\n");if(s1!=NULL){k=1;printf("%s%s%f%f%f",s1->No,s1->Name,s1->Math,s1->Chinese,s1->sum);}else{k=0;printf("your input is wrong!\n");}printf("Do you want to go on? 1 = yes,0 = no\n");scanf("%d",&m);}while(m);}void paixu() /*学生成绩排序*/{int x, y, z, m=1;float sum[50], n;s2 = head->next;x = 0;while(s2!=NULL)sum[x] = s2->sum;s2 = s2->next;x++;}for(y = 0; y < n; y++){for(z = y+1; z < n; z++)if(sum[y] < sum[z]){n=sum[z];sum[z]=sum[y];sum[y]=n;}}printf("***************paixu*******************\n");for(z = 0; z < x; z++){s2 = head->next;while(!(abs(s2->sum-sum[z]) < 1e-10))s2 = s2->next;printf("%d%s%s%f%f%f\n",m,s2->No,s2->Name,s2->Math,s2->Chinese,s2->sum);m++;}getch(); /*屏幕暂停直到用户按任意键结束*/}void xiugai() /*学生成绩修改*/{float p, q;int time;char Name[40];s=head->next;do{chaxun();if(k==1) /*调用"chaxun"函数中k的结果*/ {printf("Input the new name\n");scanf("%s",Name);printf("Input the new score of Math and Chinese\n ");scanf("%f%f",&p,&q);strcpy(s->Name,Name); /*把Name代表的字符复制到数组中*/s->Math = p;s->Chinese = q;s->sum = s->Math+s->Chinese;printf(" OK! \n");}elseprintf("Something is wrong!\n");printf("Do you want to go on? 1=yes,0=no\n");scanf("%d",&time);}while(time);}void shanchu() /*学生成绩删除*/{int m;char No[100];do{s=head->next;printf("Please input the No\n");scanf("%s",No);while(strcmp(No,s->No)!=0&&s!=NULL) /*比较两个字符串,大小相等则为0*/{s=s->next;}printf("%s%s%f%f\n",s->No,s->Name,s->Math,s->Chinese);if(strcmp(No,s->No)==0){s->next->prior=s->prior;s->prior->next=s->next;printf(" OK! \n");n--;}elseprintf("Something is wrong!\n");printf("Do you want to go on? 1=yes, 0=no\n");scanf("%d",&m);}while(m);}2回答者:20066898 - 六级2009-10-13 21:56我来评论>>提问者对于答案的评价:谢谢大家都用心改了我的程序。
不过这位老兄不但细心帮我改了这么多,还教会了我很多东西。
谢谢了!!相关内容• 高手帮看下本人的C语言程序设计错在哪里啊,急!! 2009-9-17• C语言程序设计(高手帮帮忙急~~!!) 2009-1-12• 请高手帮我修改语法错误。
(急,在线等) 2 2007-4-9• 请高手帮我做个C语言程序设计 1 2008-4-9• 希望哪个高手帮我解决一个C语言程序设计的题,谢谢 1 2009-6-28更多相关问题>>typedef struct Node{char No[40];char Name[40];float Math;float Chinese;float sum;struct Node *prior;struct Node *next;}Node,*Link;Link head, s1, s2;struct Node *s;int n = 0, k = 0;void shuru(); /*函数调用声明*/void chaxun();void paixu();void xiugai();void shanchu();main() /*主函数*/{int input;// clrscr(); /*清屏函数*/do{printf(" The inquire system for the students' scores\n ");printf("************************************************\n");printf(" 1>shuru\n "); printf(" 2>chaxun\n "); printf(" 3>paixu\n "); printf(" 4>xiugai\n "); printf(" 5>shanchu\n "); printf("************************************************\n");printf("please give me a choice:1,2,3,4,5,6\n "); scanf("%d",&input);switch(input){case 1:shuru();break;case 2:chaxun();break;case 3:paixu();break;case 4:xiugai();break;case 5:shanchu();break;default:printf("Something is wrong!\n");}}while(input);}void shuru() /*学生成绩输入*/{int m;head = (Link)malloc(sizeof(Node));s = head;do{s->next = (Link)malloc(sizeof(Node));s = s->next;s->next = NULL;printf("Please input the No,Name,Math,Chinese\n");scanf("%s%s%f%f",s->No,s->Name,&s->Math,&s->Chinese);s->sum = s->Math+s->Chinese;n++;printf("Do you want to go on? 1 = yes,0 = no\n");scanf("%d",&m);}while(m);}void chaxun() /*学生成绩查询*/{int m;char No[40];do{s1 = head->next;printf("Please input the No\n");scanf("%s",No);while((strcmp(s1->No,No)) != 0 && (s1 != NULL)) /*比较两个字符串,大小相等时值为0*/{s1=s1->next;}printf("****No****Name****Math****Chinese*******\n");if(s1!=NULL){k=1;printf("%s%s%f%f%f",s1->No,s1->Name,s1->Math,s1->Chinese,s1->sum); }else{k=0;printf("your input is wrong!\n");}printf("Do you want to go on? 1 = yes,0 = no\n");scanf("%d",&m);}while(m);}void paixu() /*学生成绩排序*/{int x, y, z, m=1;float sum[50], n;s2 = head->next;x = 0;while(s2!=NULL){sum[x] = s2->sum;s2 = s2->next;x++;}for(y = 0; y < n; y++){for(z = y+1; z < n; z++)if(sum[y] < sum[z]){n=sum[z];sum[z]=sum[y];sum[y]=n;}}printf("***************paixu*******************\n");for(z = 0; z < x; z++){s2 = head->next;while(!(abs(s2->sum-sum[z]) < 1e-10))s2 = s2->next;printf("%d%s%s%f%f%f\n",m,s2->No,s2->Name,s2->Math,s2->Chinese,s2->sum);m++;}getch(); /*屏幕暂停直到用户按任意键结束*/}void xiugai() /*学生成绩修改*/{float p, q;int time;char Name[40];s=head->next;do{chaxun();if(k==1) /*调用"chaxun"函数中k的结果*/ {printf("Input the new name\n");scanf("%s",Name);printf("Input the new score of Math and Chinese\n ");scanf("%f%f",&p,&q);strcpy(s->Name,Name); /*把Name代表的字符复制到数组中*/s->Math = p;s->Chinese = q;s->sum = s->Math+s->Chinese;printf(" OK! \n");}elseprintf("Something is wrong!\n");printf("Do you want to go on? 1=yes,0=no\n");scanf("%d",&time);}while(time);}void shanchu() /*学生成绩删除*/{int m;char No[40];do{s=head->next;printf("Please input the No\n");scanf("%s",No);while(strcmp(No,s->No)!=0&&s!=NULL) /*比较两个字符串,大小相等则为0*/{s=s->next;}printf("%s%s%f%f\n",s->No,s->Name,s->Math,s->Chinese);if(strcmp(No,s->No)==0){s->next->prior=s->prior;s->prior->next=s->next;printf(" OK! \n");n--;}elseprintf("Something is wrong!\n");printf("Do you want to go on? 1=yes, 0=no\n");scanf("%d",&m);}while(m);}我只是帮你改了错,可以编译运行的,没有改你的实现算法...你这个是双向链表,但是你的前驱根本没有使用,可以使用单向链表的二·1.先学习C语言的基础知识。