看看这个c程序错在呢了
/* 标准文档模板 */#include "Stdio.h"
#include "Conio.h"
int main(void)
{
int n=0,i=1,j=0,k=1,s=0,cho=0;
float marks[150][3],temp[150][3],t1=0,t2=0,t3=0,aver1=0,aver2=0,aver3=0,sum1=0,sum2=0,sum3=0;
char xh[150][99],name[150][99];
printf("\t\t***Student Performance Management System***\n");
/*学生学号、姓名、成绩的输入*/
printf("Enter the total number of students:\n");
scanf("%d",&n);
getchar();
for(i=1;i<=n;i++)
{
printf("Enter student %d's NO.:",i);
scanf("%s",&xh[i-1]);
getchar();
printf("Enter student &d's name:",i);
scanf("%s",&name[i-1]);
getchar();
printf("Enter student %d's first subject score:",i);
scanf("%f",&marks[i-1][0]);
getchar();
printf("Enter student %d's second subject score:",i);
scanf("%f",&marks[i-1][1]);
getchar();
printf("Enter student %d's third subject score:",i);
scanf("%f",&marks[i-1][2]);
getchar();
}
/*功能模块的选择*/
x:printf("\nChoose the function module:\n");
printf("1.Calculate the max,min,aver for each subject.\n");
printf("2.Calculate the max,min,aver for each student,and print in order.\n");
printf("3.Calculate the excellent rate and failure rate for each subject,and print graphicly.\n");
scanf("%d",&cho);
getchar();
/*保护原始数据*/
s=n;
for(i=1;i<=150;i++)
{
for(k=1;k<=3;k++)
{
temp[i-1][k-1]=marks[i-1][k-1];
}
}
switch(cho)
{
/*计算每科的最高、最低及平均分*/
case 1:
printf("%f",temp);
for(k=1;k<=n-1;k++)
{
for(j=0;j<=s-2;j++)
{
if(temp[j][0]>temp[j+1][0])
{
t1=temp[j][0];temp[j][0]=temp[j+1][0];temp[j+1][0]=t1;
}
if(temp[j][1]>temp[j+1][1])
{
t2=temp[j][1];temp[j][1]=temp[j+1][1];temp[j+1][1]=t2;
}
if(temp[j][2]>temp[j+1][2])
{
t3=temp[j][2];temp[j][2]=temp[j+1][2];temp[j+1][2]=t3;
}
}
s--;
}
for(k=1;k<=n;k++)
{
sum1=sum1+temp[k-1][0];
sum2=sum2+temp[k-1][1];
sum3=sum3+temp[k-1][2];
}
aver1=sum1/n;
aver2=sum2/n;
aver3=sum3/n;
printf("\n\nThe first subject's max,min,aver:%f,%f,%f\n",temp[n-1][0],temp[0][0],aver1);
printf("The second subject's max,min,aver:%f,%f,%f\n",temp[n-1][1],temp[0][1],aver2);
printf("The third subject's max,min,aver:%f,%f,%f\n",temp[n-1][2],temp[0][2],aver3);
printf("\nPress any key to turn back to the main menu...\n");
getch();
goto x;
break;
/*计算每人的最高、最低及平均分,并按平均分排序*/
case 2:
break;
/*计算每科的优秀率和不及格率,并图形化输出*/
case 3:
break;
/*错误处理*/
default:printf("\nerror!\n");goto x;
}
getch();
return 0;
}
没编完,只完成了第一个模块。
问题是运行到printf("Enter student &d's name:",i);
scanf("%s",&name[i-1]);
getchar();
后自动结束。下面无法继续。
在把紧接着后面的“%f”改成“%d”后,不会结束,但结果不对。