成绩系统问题,VS运行时有窗口、无显示,大家帮忙试试看哈 o(∩_∩)o (30分)
#include<stdio.h>#include<stdlib.h>
#include<conio.h>
struct ziliao{
char name[10];
int xuehao;
int com;
int math;
int eng;
int sum;
float ave;
};struct ziliao date[40];
int abc=0;
void toscanf();
void tosum();
void toave();
void toavesum();
void tomax();
void tomin();
void torank();
void toall();
void toscanf();
void caidan();
main(){
int x;
while(1);
{ caidan();
scanf("%d",&x);
switch(x){
case 1:toscanf();
break;
case 2:tosum();
break;
case 3:toave();
break;
case 4:toavesum();
printf("按任意键继续...");
getch();
break;
case 5:tomax();
printf("按任意键继续...");
getch();
break;
case 6:tomin();
printf("按任意键继续...");
getch();
break;
case 7:torank();
break;
case 8:toall();
printf("按任意键继续...");
getch();
break;
case 0:exit(0);
default: printf("操作错误,请重新输入0~8:\n");
printf("---------------------------------------\n");
}
}
}
void caidan()
{ system("cls");
printf("===================================================\n");
printf("\t1.添加学生资料\n");
printf("\t2.计算每个学生的总分\n");
printf("\t3.计算每个学生的平均分\n");
printf("\t4.输出平均总分\n");
printf("\t5.输出最高总分\n");
printf("\t6.输出最低总分\n");
printf("\t7.按照学生的总分进行从高到低排序\n");
printf("\t8.输出所有学生信息\n");
printf("\t0.退出系统\n");
printf("===================================================\n");
printf("\n输入您的选择:");
}
void toscanf1()
{ abc++;
printf("输入学号\n");
scanf("%d",&date[abc-1].xuehao);
printf("输入姓名\n");
scanf("%s",&date[abc-1].name[10]);
printf("输入计算机成绩\n");
scanf("%d",&date[abc-1].com);
printf("输入数学成绩\n");
scanf("%d",&date[abc-1].math);
printf("\n");
scanf("输入英语成绩%d",&date[abc-1].eng);
printf("\n");
scanf("输入总分%d",&date[abc-1].sum);
printf("\n");
scanf("输入平均分%d",&date[abc-1].ave);
}
void toscanf()
{int y;
while(1)
{ system("cls");
printf("返回上一层目录请按:0\n");
printf("继续请按:1\n");
printf("请输入您的选择:\n");
scanf("%d",&y);
switch(y){
case 0:return;
break;
case 1:toscanf1();
break;
default:printf("请您输入正确的0~1的数字:\n");
}
}
}
void toall()
{int i;
struct ziliao st;
printf("-----------------------");
for(i=0;i<abc;i++)
{st=date[i];
printf("\n输出学号:%d",st.xuehao);
printf("\n输出姓名:%d",st.name);
printf("\n输出计算机成绩:%d",);
printf("\n输出数学成绩:%d",st.math);
printf("\n输出英语成绩:%d",st.eng);
printf("\n输出总分:%d",st.sum);
printf("\n输出平均分:%d",st.ave);
printf("------------------------");
}
}
void tosum()
{int i;
for(i=0;i<40;i++)
{date[i].sum=date[i].com+date[i].math+date[i].eng;
}
}
void toave()
{int i;
for(i=0;i<40;i++)
{date[i].ave=(date[i].com+date[i].math+date[i].eng)/3.0;
}
}
void toavesum()
{int i;
int sum1=0;
float avesum;
void tosum();
for(i=0;i<40;i++)
sum1+=date[i].sum;
avesum=sum1/(i+1);
printf("%f",avesum);
}
void tomax()
{int i,t,max;
for(i=0;i<39;i++)
{if(date[i+1].sum>=date[i].sum)
t=date[i].sum;
date[i].sum=date[i+1].sum;
date[i+1].sum=t;
max=date[i].sum;}
printf("%d",max);
}
void tomin()
{int t,i,min;
for(i=0;i<39;i++)
if(date[i+1].sum<=date[i].sum)
t=date[i].sum;
date[i].sum=date[i+1].sum;
date[i+1].sum=t;
min=date[i].sum;
printf("%d",min);
}
void torank()
{int i,j;
int t;
for(i=0;i<39;i++)
{for(j=i+1;j<38;j++)
{if(date[j].sum >date[i].sum)
t=date[j].sum;
date[j].sum=date[i].sum;
date[i].sum=t;
}
}
}
[ 本帖最后由 晴天一阵 于 2011-6-20 14:13 编辑 ]