求C语言写的查分系统
- 提问者网友:寂寞撕碎了回忆
- 2021-04-11 05:50
- 五星知识达人网友:天凉才是好个秋
- 2021-04-11 07:10
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 5
struct students
{
int xuehao;
char name[15];
char banji[15];
float score;
}member[5]={{11001,"张三","四班",89.5},{11002,"李四","四班",87.0},{11003,"王五","四班",78.9},{11004,"王刚","四班",98.0},{11005,"张云","三班",23.0}};
void menu()
{
printf(" =-------------------------查分系统-------------------------=\n");
printf("\n");
printf(" 1.按照编号查询信息:\n");
printf(" 2.按照姓名查询信息:\n");
printf(" 3.退出.\n");
}
void main()
{
int bianhao,shuzi;
char name[15];
start:menu();
printf("请输入数字 1 2 3 :");
scanf("%d",&shuzi);
switch(shuzi)
{
case 1:
printf("请输入你要查询的编号:");
scanf("%d",&bianhao);
for(int i=0;i<5;i++)
{
if(strcmp(name,member[i].name)==0)
{
printf("该学生的详细信息如下:\n");
printf("学生学号:%d\n学生姓名:%s\n学生班级:%s学生成绩:%f\n",member[i].xuehao,member[i].name,member[i].banji,member[i].score);
break;
}
}
break;
case 2:
printf("请输入你要查询的姓名:");
scanf("%s",name);
for(int i=0;i<5;i++)
{
if(name==member[i].name)
{
printf("该学生的详细信息如下:\n");
printf("学生学号:%d\n学生姓名:%s\n学生班级:%s学生成绩:%f\n",member[i].xuehao,member[i].name,member[i].banji,member[i].score);
break;
}
}
break;
case 3:
exit(0);
default:
printf("输入错误,请重新输入:\n");
}
goto start;
}
有什么写的不恰当的地方追问!
希望对你有所帮助!