#include <stdio.h>
#include <string.h> struct student {
char name[30];
float math;
float chinese;
float english;
float average;
};
int MenuChoice(void);
int EnterAccount(void);
void Enter(struct student *fst);
void Amend(struct student *src);
void Delete(struct student *next);
void Print(struct student *out);
main()
{
struct student one[100] = {0}, *look = one;
int menu, t;
while ((menu = MenuChoice()) != 0)
if (menu >= 1 && menu <= 4 && (t = EnterAccount())) {
look = one + t;
switch (menu) {
case 1:
Enter(look);
break;
case 2:
if (strcmp(look->name, ""))
printf("学号:%d\n姓名: %s\n语文成绩: %.1f\n数学成绩:%.1f\n英语成绩: %f\n平均"成绩:%.1f\n",
t, look->name, look->chinese, look->math, look->english, look->average);
else
printf("对不起,该学号不存在!\n");
break;
case 3:
Amend(look);
break;
case 4:
Delete(look);
break;
}
}
else if (menu == 5)
Print(one);
else
printf("错误的请求!\n");
return 0;
}
int MenuChoice(void)
{
int choice;
printf("请选择:\n"
"1 - 新建学生信息\n"
"2 - 查找学生信息\n"
"3 - 修改学生信息\n"
"4 - 删除学生信息\n"
"5 - 打印学生信息\n"
"0 - 退出\n");
scanf("%d", &choice);
return choice;
}
int EnterAccount(void)
{
int ret;
printf("请输入学号:\n");
scanf("%d", &ret);
if (ret >= 1 && ret <= 100)
return ret -1;
return 0;
}
void Enter(struct student *fst)
{
printf("请输入学生姓名、语文成绩、数学成绩、英语成绩和平均成绩\n");
scanf("%s%f%f%f%f", fst->name, &fst->chinese, &fst->math, &fst->english, &fst->average);
}
void Amend(struct student *src)
{
int t;
printf("请选择:\n"
"1 - 修改学生姓名\n"
"2 - 修改学生语文成绩\n"
"3 - 修改学生数学成绩\n"
"4 - 修改学生英语成绩\n"
"5 - 修改学生平均成绩\n");
scanf("%d", &t);
switch (t) {
case 1:
printf("请输入学生的新名字\n");
scanf("%s", src->name);
break;
case 2:
printf("请输入学生新的语文成绩\n");
scanf("%f", &src->chinese);
break;
case 3:
printf("请输入学生新的数学成绩\n");
scanf("%f", &src->math);
break;
case 4:
printf("请输入学生新的英语成绩\n");
scanf("%f", &src->english);
break;
case 5:
printf("请输入学生新的平均成绩\n");
scanf("%f", &src->average);
break;
}
}
void Delete(struct student *next)
{
strcpy(next->name, "");
next->math = next->english = next->chinese = next->average = 0.0;
}
void Print(struct student *out)
{
struct student *up;
for (up = out; out < &up[100]; out++)
if (strcmp(out->name, ""))
printf("学号:%d\n姓名: %s\n语文成绩: %.1f\n数学成绩:%.1f\n英语成绩: %.1f\n平均成绩:%.1f\n",
out-up + 1, out->name, out->chinese, out->math, out->english, out->average);
}
正文
学生信息管理系统(c语言)2006-09-19 23:36:00
【评论】 【打印】 【字体:大 中 小】 本文链接:http://blog.pfan.cn/wangsdong/18592.html
阅读(12886) | 评论(1)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论