#include<stdio.h>
#include<windows.h>
int num(float *avg, int n, float from, float to){
int i;
int num = 0;
for(i=0;i<n;i++){
if(to==100)
if(avg[i]>=from&&avg[i]<=to)
num++;
else
if(avg[i]>=from&&avg[i]<to)
num++;
}
return num;
}
int main(){
const int N = 10;
int i;
float avg[N];
float maths,linal,pys,cpg;
printf("Input %d student's score(four classes):\n",N);
for(i=0;i<N;i++){
scanf("%f%f%f%f",&maths,&linal,&pys,&cpg);
avg[i] = (maths+linal+pys+cpg)/4.0;
}
printf("\nAverage score: ");
for(i=0;i<N;i++)
printf("%0.2f ",avg[i]);
printf("\n");
printf("Number of peopeo with average score between 0 and 60: %d\n",num(avg,N,0,60));
printf("Number of peopeo with average score between 60 and 70: %d\n",num(avg,N,60,70));
printf("Number of peopeo with average score between 70 and 80: %d\n",num(avg,N,70,80));
printf("Number of peopeo with average score between 80 and 90: %d\n",num(avg,N,80,90));
printf("Number of peopeo with average score between 90 and 100: %d\n",num(avg,N,90,100));
system("pause");
return 1;
}
追问我运行显示一个错误呀哥们,你能帮我再看看吧
追答我电脑是正常运行的? 你什么错误?
编程环境是VC吗?
追问就是Vc呀可能是这里看的有问题,,你能发world文档给我不,谢啦
追答你直接复制粘贴跟我用word发有区别吗?
这么简单的c编程,随便看看就能理解程序是怎么写的了吧!
要不你就把错误代码贴出来
追问e:\大学资料\microsoft visual studio\common\msdev98\bin\cpp1.cpp(2) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
执行 cl.exe 时出错.
Cpp1.exe - 1 error(s), 0 warning(s)
追答那你把#include和 结尾处的 system("pause");去掉