求解决WHILE 与FOR转换的问题(关于计算M名学生N门课程个人平均成绩)
用FOR语句#include <stdio.h>
main ()
{int m,n,i,j;
float v,s,x;
printf("press the number of students and the number of the courses\n");
scanf("%d,%d",&m,&n);
i=1;
for(;i<=m;i=i+1)
{printf("%d",i);
for(s=0,j=1;j<=n;j++ )
{
scanf("%f",&x);
s=s+x;
}
v=s/n;
printf("%f\n",v);
}
}
用WHILE语句
#include <stdio.h>
main ()
{int m,n,i,j;
float v,s,x;
printf("press the number of students and the number of the courses\n");
scanf("%d,%d",&m,&n);
i=1;
while (i<=m)
{
printf("the %d student\n",i);
s=0;
j=1;
while (j<=n)
{
printf("press the %d course's score=\n",j);
scanf("%f",&x);
s=s+x;
j=j+1;
}
v=s/n;
printf("%f\n",v);
i=i+1;
}
}
用FOR语句怎么使和用WHILE语句一样在应用程序中出现提示语句如(请输入第K名成绩)