自己写的程序运行结果不对。
自己写的计算的程序,能运行成功但是运行结果不对,哪位大师能帮忙改一下啊?运行结果的范围应该在0到4.67之间!程序代码:
#include <stdio.h> void main(void) { int i,n,a[15],b[15],c[15],S; int z1,z2,z3,z4,z5,z6,z7,z8,z9,z10,z11,z12,z13,z14,z15; printf("Input subject's numbers:"); scanf("%d",&n); printf("Input the subject's scores:\n"); for(i=0;i<=n;i++); { scanf("%d%d",a[i],c[i]); if(a[i]>=95&&a[i]<=100) b[i]=4.67; else if (a[i]>=90&&a[i]<=94) b[i]=4.33; else if (a[i]>=87&&a[i]<=89) b[i]=4.00; else if (a[i]>=84&&a[i]<=86) b[i]=3.67; else if (a[i]>=80&&a[i]<=83) b[i]=3.33; else if (a[i]>=77&&a[i]<=79) b[i]=3.00; else if (a[i]>=74&&a[i]<=76) b[i]=2.67; else if (a[i]>=70&&a[i]<=73) b[i]=2.33; else if (a[i]>=67&&a[i]<=69) b[i]=2.00; else if (a[i]>=64&&a[i]<=66) b[i]=1.67; else if (a[i]>=61&&a[i]<=63) b[i]=11.33; else if (a[i]==60) b[i]=1.00; else b[i]=0; switch(i) { case1: z1=b[i]*c[i];break; case2: z2=b[i]*c[i];break; case3: z3=b[i]*c[i];break; case4: z4=b[i]*c[i];break; case5: z5=b[i]*c[i];break; case6: z6=b[i]*c[i];break; case7: z7=b[i]*c[i];break; case8: z8=b[i]*c[i];break; case9: z9=b[i]*c[i];break; case10: z10=b[i]*c[i];break; case11: z11=b[i]*c[i];break; case12: z12=b[i]*c[i];break; case13: z13=b[i]*c[i];break; case14: z14=b[i]*c[i];break; case15: z15=b[i]*c[i];break; } S=(z1+z2+z3+z4+z5+z6+z7+z8+z9+z10+z11+z12+z13+z14+z15)/(c[1]+c[2]+c[3]+c[4]+c[5]+c[6]+c[7]+c[8]+c[9]+c[10]+c[11]+c[12]+c[13]+c[14]+c[15]); printf("%f,S"); } }