急!!![80分]求一C语言程序

本人对C语言一窍不通(TC),却要交一个课程设计,请各位大虾帮帮忙!

题目如下
使用结构体,管理学生的成绩。
1. 建立一个结构体,可以保存学生的学号、语文、数学、外语,总分,假设学生数目不超过50个。
2.建立一个函数,可以从键盘依次输入每个学生的学号和语文、数学、外语,并能够计算总分。
3. 建立一个函数,提示操作者输入要修改数据的学生的学号,然后查找,找到,显示该学生的数据,操作者可以修改数据,修改后能计算并显示;找不到,显示“zhaobudao xuehao!”。
4. 建立一个函数,提示操作者输入要查找数据的学生的学号,然后查找,找到,显示该学生的数据;找不到,显示“zhaobudao cixuehao!”。
5.建立一个函数,提示操作者输入要删除数据的学生的学号,然后查找,找到,删除该学生的数据;找不到,显示“zhaobudao cixuehao!”。
6.建立一个菜单,如下图所示
1.依次输入成绩
2.修改学生成绩
3.查询学生成绩
4.退 出
操作员根据提示输入1,2,3,然后调用相应的函数,操作员输入4,结束本程序。
本人只有80分,对不住大家!

#include <stdio.h>

// 1结构体,可以保存学生的学号、
//语文、数学、外语,总分,假设学生数目不超过50个
struct Student
{
int No; //学号
float Chinese; //语文
float math; //数学
float English; //外语
float Sum; //总分
}student[50];

//全局变量,记录学生的个数
int n = 0;

//根据学号查找是否存在,-1不存在
int isRepeat(int No);

/*显示提示信息
6.建立一个菜单,如下图所示
1.依次输入成绩
2.修改学生成绩
3.查询学生成绩
4.删除学生成绩
5.退 出 */
void ShowMessage();

/*2 从键盘依次输入每个学生的学号
和语文、数学、外语,并能够计算总分*/
void Input();

/*3 提示操作者输入要修改数据的学生的学号,
然后查找,找到,显示该学生的数据,操作者可以修改数据,
修改后能计算并显示;找不到,显示“zhaobudao xuehao!”。*/
void Update();

/*4 提示操作者输入要查找数据的学生的学号,
然后查找,找到,显示该学生的数据;找不到,
显示“zhaobudao cixuehao!”。*/
void Query();

/*5 提示操作者输入要删除数据的学生的学号,
然后查找,找到,删除该学生的数据;找不到,
显示“zhaobudao cixuehao!”。
在这里删除采用的是把相应的字段置0。*/
void Delete();

//主函数
int main()
{
int Choice;

while (1)
{
ShowMessage();
scanf("%d", &Choice);
switch(Choice)
{
case 1:
Input();
break;
case 2:
Update();
break;
case 3:
Query();
break;
case 4:
Delete();
break;
case 5:
return 0;
break;
default:
ShowMessage();
break;
}
}
}

//根据学号查找是否存在,-1不存在
int isRepeat(int No)
{
int i;
for (i=0; i<n; ++i)
{
if (student[i].No==No)
{
return i;
}
}
return -1;
}

/*显示提示信息
6.建立一个菜单,如下图所示
1.依次输入成绩
2.修改学生成绩
3.查询学生成绩
4.删除学生成绩
5.退 出 */
void ShowMessage()
{
printf("*************************************************\n");
printf("* *\n");
printf("* 欢迎使用学生成绩管理系统 *\n");
printf("* *\n");
printf("*************************************************\n");
printf(" 选择您要进行的操作(1—4)\n");
printf(" 1 依次输入成绩\n");
printf(" 2 修改学生成绩\n");
printf(" 3 查询学生成绩\n");
printf(" 4 删除学生成绩\n");
printf(" 5 退 出\n");
}

/*2 从键盘依次输入每个学生的学号
和语文、数学、外语,并能够计算总分*/
void Input()
{
int No;
printf("第%d学生:\n", n+1);
printf("学号:");
scanf("%d",&No);
if (-1!=isRepeat(No))
{
printf("你输入的学号己存在!\n");
}
else
{
student[n].No = No;
printf("语文成绩:");
scanf("%f",&student[n].Chinese);
printf("数学成绩:");
scanf("%f",&student[n].math);
printf("外语成绩:");
scanf("%f",&student[n].English);
student[n].Sum = student[n].Chinese + student[n].math + student[n].English;
++n;
printf("输入完毕!\n");
}

}

/*3 提示操作者输入要修改数据的学生的学号,
然后查找,找到,显示该学生的数据,操作者可以修改数据,
修改后能计算并显示;找不到,显示“zhaobudao xuehao!”。*/
void Update()
{
int No;
int i;
printf("请输入要修改的学生学号:");
scanf("%d", &No);
i = isRepeat(No);
if (-1==i)
{
printf("找不到学号!\n");
}
else
{
printf("语文成绩:%.1f 修改为:", student[i].Chinese);
scanf("%f", &student[i].Chinese);
printf("数学成绩:%.1f 修改为:", student[i].math);
scanf("%f", &student[i].math);
printf("外语成绩:%.1f 修改为:", student[i].English);
scanf("%f", &student[i].English);
student[i].Sum = student[i].Chinese + student[i].math + student[i].English;
printf("修改完毕!\n");
}
}

/*4 提示操作者输入要查找数据的学生的学号,
然后查找,找到,显示该学生的数据;找不到,
显示“zhaobudao cixuehao!”。*/
void Query()
{
int No;
int i;
printf("请输入要查询的学生学号:");
scanf("%d", &No);
i = isRepeat(No);
if (-1==i)
{
printf("找不到此学号!\n");
}
else
{
printf("语文成绩:%.1f\n", student[i].Chinese);
printf("数学成绩:%.1f\n", student[i].math);
printf("外语成绩:%.1f\n", &student[i].English);
printf("输出完毕!\n");
}
}

/*5 提示操作者输入要删除数据的学生的学号,
然后查找,找到,删除该学生的数据;找不到,
显示“zhaobudao cixuehao!”。
在这里删除采用的是把相应的字段置0。*/
void Delete()
{
int No;
int i;
printf("请输入要删除的学生学号:");
scanf("%d", &No);
i = isRepeat(No);
if (-1==i)
{
printf("找不到此学号!\n");
}
else
{
student[i].No = -1;
student[i].Chinese = 0;
student[i].math = 0;
student[i].English = 0;
printf("删除完毕!\n");
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-12-26
#include <stdio.h>
struct
{
int xuehao;
float yuwen,shuxue,waiyu,zongfen;
}
xuesheng[100];
static num2;
main()
{
int num1;
num1=0;
num2=1;
while(1)
{
printf("please choose:\n");
printf("1.yici shuru chengji\n");
printf("2.xiugai xuesheng chengji\n");
printf("3.chaxun xuesheng chengji\n");
printf("4.tuichu\n");
scanf("%d",&num1);
switch(num1)
{
case 1:input_information(num2);
num2++;break;
case 2:xiugai_chengji();break;
case 3:chaxun_chengji();break;
case 4:exit();
}
}
}
int input_information(int num)
{
float total;
printf("please input xuehao yuwen shuxue waiyu\n");
scanf("%d %f %f %f",&xuesheng[num].xuehao,&xuesheng[num].yuwen,&xuesheng[num].shuxue,&xuesheng[num].waiyu);
total=xuesheng[num].yuwen+xuesheng[num].shuxue+xuesheng[num].waiyu;
xuesheng[num].zongfen=total;
}

int xiugai_chengji()
{
int i,num3;
float total;
i=0;
num3=0;
printf("shuru xuehao:\n");
scanf("%d",&num3);
for (i=1;i<num2;i++)
if(num3==xuesheng[i].xuehao)
{
printf("please input xuehao yuwen shuxue waiyu\n");
scanf("%d %f %f %f",&xuesheng[num3].xuehao,&xuesheng[num3].yuwen,&xuesheng[num3].shuxue,&xuesheng[num3].waiyu);
total=xuesheng[num3].yuwen+xuesheng[num3].shuxue+xuesheng[num3].waiyu;
xuesheng[num3].zongfen=total;
return;
}
printf("zhaobudao cixuehao!\n");
return;
}
int chaxun_chengji()
{
int i;
int num3;
printf("shuru xuehao:\n");
scanf("%d",&num3);
for (i=1;i<num2;i++)
if(num3==xuesheng[i].xuehao)
{
printf("xuehao yuwen shuxue waiyu zongfen\n");
printf("%d %6f %6f %6f %6f\n",xuesheng[num3].xuehao,xuesheng[num3].yuwen,xuesheng[num3].shuxue,xuesheng[num3].waiyu,xuesheng[num3].zongfen);
return;
}
printf("zhaobudao cixuehao!\n");
return;
}

总算写完了测试也通过了.给分吧!
qq 64924930本回答被提问者采纳
第2个回答  2007-12-27
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define N 50
#define NULL 0
struct student
{
char num[50];
float Chinese;
float Math;
float English;
float Total;
struct student *next;
}stu[N];

void main()
{
struct student *input();
void alter(struct student *);
void search(struct student *);
struct student *head=NULL;
for(;;)
{
switch(menu_select())
{
case 1:head=input();break;
case 2:alter(head);break;
case 3:search(head);break;
case 4:printf("Goodbye!\n");exit(0);
}
}

clrscr();
}

int menu_select()
{
int ch;
printf("1.Enter the static of the students.\n");
printf("2.Alter the static of the student.\n");
printf("3.Search the static of the student.\n");
printf("4.Quit.\n");
do
{
printf("Make a chioce.");
scanf("%d",&ch);
}while(ch>4 || ch<1);
return(ch);
}

struct student *input()
{
struct student *p1,*p2,*p3,*head;
int i=1,j,k,n=0;
printf("input the static:\n");
p1=p2=(struct student *) malloc (sizeof(struct student));
head=NULL;
printf("num:");
scanf("%s",p1->num);
if(strcmp(p1->num,"0")==0)/*输入0时可以结束*/
goto end;
printf("Chinese score:");
scanf("%f",&p1->Chinese);
printf("English score:");
scanf("%f",&p1->English);
printf("Math score:");
scanf("%f",&p1->Math);
p1->Total=p1->Chinese+p1->English+p1->Math;
p2=p1;
while(strcmp(p1->num,"0")!=0 && i<50)
{
i++;
n=n+1;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct student *) malloc (sizeof(struct student));
printf("num:");
scanf("%s",p1->num);
if(strcmp(p1->num,"0")==0)
goto end;
printf("Chinese score:");
scanf("%f",&p1->Chinese);
printf("English score:");
scanf("%f",&p1->English);
printf("Math:");
scanf("%f",&p1->Math);
p1->Total=p1->Chinese+p1->English+p1->Math;
}
end:
p2->next=NULL;
p1=head;
printf("\tNUM\tChinese\tEnglish\tMath\tTotal\n");
while(p1!=NULL)
{
printf("\t%-5s\t%-5.2f\t%-5.2f\t%-5.2f\t%-5.2f\n",p1->num,p1->Chinese,p1->English,
p1->Math,p1->Total);
p1=p1->next;
}
return(head);
}

void alter(struct student *head)
{
struct student *p1,*p2;
char ser[50];
int i,j,k;
if(head==NULL)
printf("zhaobudao xuehao!\n");
else
{
printf("input the number to alter:");
scanf("%s",ser);
p1=p2=head;
while(p1->next!=NULL && (strcmp(ser,p1->num)!=0))
{
p2=p1;
p1=p1->next;
}
if(strcmp(ser,p1->num)==0)
{
printf("Enter the new static:\n");
printf("Chinese:");
scanf("%f",&p1->Chinese);
printf("English:");
scanf("%f",&p1->English);
printf("Math:");
scanf("%f",&p1->Math);
p1->Total=p1->Chinese+p1->English+p1->Math;
}
else
printf("zhaobudao xuehao!");
}
p1=head;
printf("\tNUM\tChinese\tEnglish\tMath\tTotal\n");
while(p1!=NULL)
{
printf("\t%s\t%5.2f\t%5.2f\t%5.2f\t%5.2f\n",p1->num,
p1->Chinese,p1->English,p1->Math,p1->Total);
p1=p1->next;
}

}

void search(struct student *head)
{
struct student *p1;
int i,j;
char ser[50];
printf("input the num to search:");
scanf("%s",ser);
if(head==NULL)
printf("\nzhaobudao xuehao!\n");
p1=head;
while((strcmp(ser,p1->num)!=0) && p1->next!=NULL)
{
p1=p1->next;
}
if(strcmp(ser,p1->num)==0)
{
printf("\tNUM\tChinese\tEnglish\tMath\tTotal\n");
printf("\t%s\t%-5.2f\t%-5.2f\t%-5.2f\t%5.2f\n",p1->num,p1->Chinese,p1->English,p1->Math,p1->Total);
}
else
printf("zhaobudao xuehao!\n");
}

总算做完了,不过看见已经有人给你答案了,择优录用,任君选择吧
第3个回答  2007-12-26
这个程序好像不太难,80分也不低了,不过,最近感冒的挺厉害,头脑不太清楚.不过,记得谭浩强C语言的书,后面结构体那块的例子,你改改应该就可以了的了.
第4个回答  2007-12-26
这程序这么复杂,80分没人愿意去写啊!
相似回答