之前的课设,自己目前掌握编程知识太少,今天是以前的课设。以后会逐渐发新的IT知识

#include
#include
#include
#include
#define STU_BASE_SIZE 32 //定义学生基本信息不得超过32个字节
#define STU_NUM 1000 //定义学生数量不得超过1000人

struct STU {
char szID[STU_BASE_SIZE]; //学号
char szName[STU_BASE_SIZE];//
char szSex[STU_BASE_SIZE];
int szChinese;
int szMath;
int szEnglish;
};

struct STU g_stuNode[STU_NUM];
int g_iNum =0;

void mima()
{int i,j;
char a[6];
printf("请输入密码");
for(i=0;i<3;i++)
{
for(j=0;j<6;j++)
{a[j]=getch();
printf("*");
}
if(strcmp(a,"123456")!=0)
printf("密码错误");
else
{
printf("登陆成功");
break;
}
}
}

void Add()
{printf("请输入学号");
scanf("%s",g_stuNode[g_iNum+1].szID);
printf("请输入姓名");
scanf("%s",g_stuNode[g_iNum+1].szName);
printf("请输入性别");
scanf("%s",g_stuNode[g_iNum+1].szSex);
printf("请输入数学成绩");
scanf("%d",&g_stuNode[g_iNum+1].szMath);
printf("请输入语文成绩");
scanf("%d",&g_stuNode[g_iNum+1].szChinese);
printf("请输入英语成绩");
scanf("%d",&g_stuNode[g_iNum+1].szEnglish);
g_iNum++;
printf("添加学生信息成功\n");
system("pause");
}//添加学生信息

void youlan()
{struct STU temp;
int i,j,k;
printf("学生信息如下:");
for(i=1;i{k=i;
for(j=i+1;jif(g_stuNode[j].szID{
k=j;
temp=g_stuNode[k];
g_stuNode[k]=g_stuNode[i];
g_stuNode[i]=temp;}
}
for(i=1;i{printf("学号:%s\n",g_stuNode[i].szID);
printf("姓名:%s\n",g_stuNode[i].szName);
printf("性别:%s\n",g_stuNode[i].szSex);
printf("数学:%d\n",g_stuNode[i].szMath);
printf("语文:%d\n",g_stuNode[i].szChinese);
printf("英语:%d",g_stuNode[i].szEnglish);
printf("\n");
}
system("pause");
}

void paixu()
{struct STU temp;
int i,j,k;
printf("学生信息如下:");
for(i=1;i{k=i;
for(j=i+1;jif(strcmp(g_stuNode[j].szID,g_stuNode[k].szID)<0)
{
k=j;
temp=g_stuNode[k];
g_stuNode[k]=g_stuNode[i];
g_stuNode[i]=temp;}
}
for(i=1;i{printf("学号:%s\n",g_stuNode[i].szID);
printf("姓名:%s\n",g_stuNode[i].szName);
printf("性别:%s\n",g_stuNode[i].szSex);
printf("数学:%d\n",g_stuNode[i].szMath);
printf("语文:%d\n",g_stuNode[i].szChinese);
printf("英语:%d",g_stuNode[i].szEnglish);
printf("\n");
}
system("pause");
}

void Look()
{int m,i;
char b[32];
char a[32];
printf("学号输入:1,姓名输入:2");
printf("\n");
scanf("%d",&m);
if(m==1)
{printf("请输入所要查询学生学号:");
scanf("%s",a);
for(i=1;iif(a==g_stuNode[i].szID)
printf("学号:%s\n",g_stuNode[i].szID);
printf("姓名:%s\n",g_stuNode[i].szName);
printf("性别:%s\n",g_stuNode[i].szSex);
printf("数学:%d\n",g_stuNode[i].szMath);
printf("语文:%d\n",g_stuNode[i].szChinese);
printf("英语:%d",g_stuNode[i].szEnglish);
printf("\n");
}
else if(m==2)
{printf("请输入所要查询学生姓名:");
scanf("%s",b);
for(i=1;iif(b==g_stuNode[i].szName)
{printf("学号:%s\n",g_stuNode[i].szID);
printf("姓名:%s\n",g_stuNode[i].szName);
printf("性别:%s\n",g_stuNode[i].szSex);
printf("数学:%d\n",g_stuNode[i].szMath);
printf("语文:%d\n",g_stuNode[i].szChinese);
printf("英语:%d",g_stuNode[i].szEnglish);
printf("\n");}
}
system("pause");
}

void Del()
{ int i=0,k=-1;
char j[32];
printf("学号 姓名 性别 数学 语文 英语\n");
for(i=0; i{
printf("%s ", g_stuNode[i+1].szID);
printf("%s ", g_stuNode[i+1].szName);
printf("%s ", g_stuNode[i+1].szSex);
printf("%d ", g_stuNode[i+1].szMath);
printf("%d ", g_stuNode[i+1].szChinese);
printf("%d \n", g_stuNode[i+1].szEnglish);
}
printf("请输入要删除的人员学号:");
scanf("%s",j);
for(i=1;i<=g_iNum+1;i++)
{if(strcmp(j,g_stuNode[i].szID)==0)
{k=i;
}
}
if(k!=-1)
{if(k==g_iNum )
g_iNum--;
else
{
for(i=k;i<=g_iNum+1;i++)
{
g_stuNode[i]=g_stuNode[i+1];
}
g_iNum--;
}
printf("删除学生信息成功\n");
system("pause");
}
}

void Mod()
{
int i=0;
int x;
printf("学号 姓名 性别 数学 语文 英语\n");
for(i=0;i{
printf("%s ", g_stuNode[i+1].szID);
printf("%s ", g_stuNode[i+1].szName);
printf("%s ", g_stuNode[i+1].szSex);
printf("%d ", g_stuNode[i+1].szMath);
printf("%d ", g_stuNode[i+1].szChinese);
printf("%d \n", g_stuNode[i+1].szEnglish);
}
printf("请输入要修改的人员序数:");
scanf("%d",&x);
printf("请输入姓名:");
scanf("%s",g_stuNode[x].szName);
printf("请输入性别:");
scanf("%s",g_stuNode[x].szSex);
printf("请输入数学成绩:");
scanf("%d",&g_stuNode[x].szMath);
printf("请输入语文成绩:");
scanf("%d",&g_stuNode[x].szChinese);
printf("请输入英语成绩:");
scanf("%d",&g_stuNode[x].szEnglish);
printf("修改学生信息成功\n");
system("pause");
}

void tongji()
{
int all[g_iNum-1],i,j,k1,k2,k3,x1,x2,x3,t,a1,b1,c1,a2,b2,c2,a3,b3,c3;
a1=b1=c1=a2=b2=c2=a3=b3=c3=0;
float av1=0,av2=0,av3=0;
for(i=1;i<=g_iNum;i++)
{
all[i]=g_stuNode[i].szMath+g_stuNode[i].szChinese+g_stuNode[i].szEnglish;
av1=av1+g_stuNode[i].szMath;
av2=av2+g_stuNode[i].szChinese;
av3=av3+g_stuNode[i].szEnglish;
}
av1=av1/g_iNum;
av2=av2/g_iNum;
av3=av3/g_iNum;
k1=g_stuNode[1].szMath;
k2=g_stuNode[1].szChinese;
k3=g_stuNode[1].szEnglish;
for(i=1;i<=g_iNum;i++)
{
if(k1k1=g_stuNode[i].szMath;
if(k2k2=g_stuNode[i].szChinese;
if(k3k3=g_stuNode[i].szEnglish;
}
for(i=1;i<=g_iNum;i++)
{
if(x1>g_stuNode[i].szMath)
x1=g_stuNode[i].szMath;
if(x2>g_stuNode[i].szChinese)
x2=g_stuNode[i].szChinese;
if(x3>g_stuNode[i].szEnglish)
x3=g_stuNode[i].szEnglish;
}
for(i=1;i<=g_iNum;i++)
{
if(g_stuNode[i].szMath>=80&&g_stuNode[i].szMath<=100)
a1=a1+1;
else if(g_stuNode[i].szMath>=60&&g_stuNode[i].szMath<80)
b1=b1+1;
else
c1=c1+1;
}
for(i=1;i<=g_iNum;i++)
{
if(g_stuNode[i].szChinese>=80&&g_stuNode[i].szChinese<=100)
a2=a2+1;
else if(g_stuNode[i].szChinese>=60&&g_stuNode[i].szChinese<80)
b2=b2+1;
else
c2=c2+1;
}
for(i=1;i<=g_iNum;i++)
{
if(g_stuNode[i].szEnglish>=80&&g_stuNode[i].szEnglish<=100)
a3=a3+1;
else if(g_stuNode[i].szEnglish>=60&&g_stuNode[i].szEnglish<80)
b3=b3+1;
else
c3=c3+1;
}
printf("每个同学的总分为:\n");
for(i=1;i<=g_iNum;i++)
printf("%d ",all[i]);
printf("\n各科平均分为:");
printf("数学:%f 语文:%f 英语:%f\n",av1,av2,av3);
printf("数学最高分为:%d 最低分为:%d\n",k1,x1);
printf("语文最高分为:%d 最低分为:%d\n",k2,x2);
printf("英语最高分为:%d 最低分为:%d\n",k3,x3);
printf("100~80分为A段,79~60为B段,60一下为C段。\n");
printf("数学A段有%d人,B段有%d人,C段有%d人。\n",a1,b1,c1);
printf("语文A段有%d人,B段有%d人,C段有%d人。\n",a2,b2,c2);
printf("英语A段有%d人,B段有%d人,C段有%d人。\n",a3,b3,c3);

system("pause");
}

int Menu()
{
{
int ch=0;
system("cls");
printf("\n");
printf("
\n");
printf("
学生管理系统 \n");
printf("
\n");
printf("
\n");
printf(" \n");
printf(" 1. 添加学生信息 \n");
printf(" 2. 游览学生记录 \n");
printf(" 3. 排序学生记录 \n");
printf(" 4. 查询学生记录 \n");
printf(" 5. 删除学生记录 \n");
printf(" 6. 修改学生记录 \n");
printf(" 7. 统计学生记录 \n");
printf(" 0. 退出系统 \n");
printf(" \n");
printf("***\n");
printf("请选择:");
scanf("%d", &ch);
return ch;
}
system("pause");
getch();
exit(0);
}
int main()
{
int ch=1;
mima();
while(ch)
{
ch=Menu();
switch(ch)
{
case 1:
Add();
break;
case 2:
youlan();
break;
case 3:
paixu();
break;
case 4:
Look();
break;
case 5:
Del();
break;
case 6:
Mod();
break;
case 7:
tongji();
break;
case 0:
break;
default:
printf("输入错误,");
system("pause");
break;
}
}
return 0;
}