求只用c语言编写的学生成绩管理系统。

2025-02-22 14:43:29
推荐回答(6个)
回答1:

#include
#include
#include
#define N 50
struct student
{
int num; //学号
char name[15]; //姓名
double score[3]; //3门成绩
double ave; //平均成绩
};

void menu(); //显示主菜单
struct student input(); //输入函数
void display(struct student s[],int total); //显示学生信息
void sort(struct student s[],int total); //冒泡排序
void insert(struct student s[],int total); //插入学生(自动排序)
int del(struct student s[],int total); //删除学生
void searchNum(struct student s[],int total); //按学号查询

void main()
{
struct student stu[N];
char ch;
int total=0,select; //total为学生总数,select为选择
do{
system("cls");
menu();
printf("\t\t\t\t\t 请输入你的选择: ");
fflush(stdin);
scanf("%d",&select);
system("cls");
switch(select)
{
case 1:
do
{
system("cls");
stu[total]=input();
total++; //人数+1
printf("\n是否继续Y/y: ");
fflush(stdin);
ch=getchar();
}while(ch=='Y'||ch=='y');
printf("\n");
break;
case 2:
display(stu,total); //显示
printf("\n");
break;
case 3:
sort(stu,total); //排序
display(stu,total); //显示
break;
case 4:
searchNum(stu,total);
break;
case 5:
do
{
system("cls");
display(stu,total); //显示
insert(stu,total); //插入
total++; //人数+1
system("cls");
display(stu,total); //显示
printf("\n是否继续插入学员Y/y: ");
fflush(stdin);
ch=getchar();
printf("\n");
}while(ch=='Y'||ch=='y');
break;
case 6:
do
{
system("cls");
display(stu,total); //显示
if(del(stu,total)) //删除
{
total--; //人数-1
system("cls");
display(stu,total); //显示
}
else
{
printf("\n\t该学号不存在\n\n\t");
system("pause");
system("cls");
display(stu,total);
}
printf("\n是否继续删除学员Y/y: ");
fflush(stdin);
ch=getchar();
printf("\n");
}while(ch=='Y'||ch=='y');
break;
case 7:
printf("\n\n\n\n\n\n\n\n\n\t\t\t此操作将删除所有记录");
printf("\n\n\t\t\t 是否继续Y/y: ");
fflush(stdin);
ch=getchar();
if(ch=='Y'||ch=='y')
{
total=0;
}
break;
default:
printf("\n\n\n\n\n\n\n\n\n\t\t\t真的要退出吗Y/y: ");
fflush(stdin);
ch=getchar();
printf("\n\n\t\t");
if(ch=='y'||ch=='Y')
{
exit(0);
}
break;
}
system("pause");
}while(1);
}
struct student input() //输入函数
{
int i;
double sum=0;
struct student temp;
printf("\n请输入学号: ");
scanf("%d",&temp.num);
printf("\n请输入姓名: ");
fflush(stdin);
gets(temp.name);
printf("\n请输入数学成绩: ");
scanf("%lf",&temp.score[0]);
printf("\n请输入语文成绩: ");
scanf("%lf",&temp.score[1]);
printf("\n请输入英语成绩: ");
scanf("%lf",&temp.score[2]);
for(i=0;i<3;i++)
{
sum+=temp.score[i];
}
temp.ave=sum/3;
return temp;
}
void display(struct student s[],int total) //输出函数
{
int i;
printf("\t学号\t姓名\t语文\t数学\t英语\t平均\n\n");
for(i=0;i {
printf("\t%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n\n",s[i].num,s[i].name,s[i].score[0],s[i].score[1],s[i].score[2],s[i].ave);
}
}
void sort(struct student s[],int total) //排序
{
int i,j;
struct student temp;
for(i=0;i {
for(j=0;j {
if(s[j].ave {
temp=s[j];
s[j]=s[j+1];
s[j+1]=temp;
}
}
}
}
void insert(struct student s[],int total) //插入
{
struct student temp;
int i,k;
temp=input();
for(i=0;i {
if(temp.ave>s[i].ave)
break;
}
k=i;
for(i=total;i>k;i--)
{
s[i]=s[i-1];
}
s[k]=temp;
}
int del(struct student s[],int total) //删除
{
int temp,i,j;
printf("\t请输入要删除的学号: ");
scanf("%d",&temp);
for(i=0;i {
if(temp==s[i].num)
break;
}
if(i {
for(j=i;j {
s[j]=s[j+1];
}
return 1;
}
else
{
return 0;
}
}
void menu()
{
printf("\n\n\t ===================================================\n\n");
printf("\t\t1.输入学生信息");
printf("\t\t2.显示学生信息\n\n");
printf("\t\t3.排序\t");
printf("\t\t4.查询学生(按学号)\n\n");
printf("\t\t5.插入学生信息");
printf("\t\t6.删除学生信息\n\n");
printf("\t\t7.清除记录");
printf("\t\t8.退出\n\n");
printf("\t ====================================================\n\n");
}

void searchNum(struct student s[],int total) //查询
{
int num,i;
printf("\n\t请输入要查询的学号:\n\n\t");
scanf("%d",&num);
printf("\n");
for(i=0;i {
if(num==s[i].num)
break;
}
if(i {
printf("\t学号\t姓名\t语文\t数学\t英语\t平均\n\n");
printf("\t%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n\n\t",s[i].num,s[i].name,s[i].score[0],s[i].score[1],s[i].score[2],s[i].ave);
}
else
printf("\t该学号不存在\n\n\t");
}

回答2:

C语言可以写界面,但你要懂比较多的系统API
加上你的这个项目还要用到数据库,你还要知道数据库的API
我现在也在学API大概可以写出个你要求的模样
但对于没学过C语言的你,建议你不要考虑用C写,这是不可能的任务,我写出来你也没发修改成你想要的界面,因为界面也要写代码,不像VB那么简单

我不知道你的用途,如果是作业建议你放弃用C,不过大家还可以继续探讨

回答3:

最近怎么找个这个程序的人好多,
刚帮一个人修改了一份,你要是要的话
我也发给你一份

回答4:

C语言?怎么可能?
你的这个系统难道没有界面吗?
或者是用DOS界面?。。。

回答5:

已发到你邮箱了,请查收!满意的话别忘了加分哦!

回答6:

用c来编辑界面?
你还是杀了我吧