改了一下!不过还是 有一个错误答案!HIT-Online Judge,process result is Okey.
result has 1 wrong answers.
#include <stdio.h>
#include <stdlib.h>
#define M "ID LAB FORUM FINAL TOTAL GRADE"
#define N 1000
#include <math.h>
int main()
{
unsigned long m, n, ID[N];
int LAB[N], FORUM[N];
int l, FINAL[N], i, j, k;
int score1[N], score2[N], score3[N];
float num1, num2, num3, num4;
scanf("%ld%ld", &m, &n);
for(i = 0;i < m;i ++)
{
int int_integer(float m);
int sum = 0;
scanf("%ld", &ID[i]);
for(j = 0;j < n;j ++)
{
scanf("%d", &LAB[j]);
sum += LAB[j];
}
score1[i] = int_integer(sum*0.50/n);
scanf("%d", &l);
sum = 0;
for(k = 0;k < l;k ++)
{
scanf("%d", &FORUM[k]);
sum += FORUM[k];
}
score2[i] = int_integer(sum*1.00/k);
scanf("%d", &FINAL[i]);
score3[i] = score1[i] + score2[i] + int_integer(FINAL[i]*0.45);
}
puts(M);
int zhang(char ch);
zhang('-');
int score(int a);
num1 = num2 = num3 =0;
for(i = 0;i < m;i ++)
{
int int_integer(float m);
printf("%ld %d %d %d %d ", ID[i], score1[i], score2[i], int_integer(FINAL[i]*0.45), score3[i]);
printf("%c\n", score(score3[i]));
num1 += score1[i];
num2 += score2[i];
num3 += score3[i];
num4 += int_integer(FINAL[i]*0.45);
}
zhang('-');
printf("Average: %.2f %.2f %.2f %.2f ", num1/m, num2/m, num4/m, num3/m);
printf("%c", score(num3/n));
return 0;
}
int zhang(char ch)
{
int i;
for(i = 0;i < 65;i ++)
printf("%c", ch);
printf("\n");
return 0;
}
int int_integer(float m)
{
if(fabs(m - (int)m) < 1E-10)
return (int)m;
else
return (int)m + 1;
}
int score(int a)
{
a /= 10;
switch(a)
{
case 10:
case 9:
putchar('A');
break;
case 8:
putchar('B');
break;
case 7:
putchar('C');
break;
case 6:
putchar('D');
break;
default:
putchar('E');
break;
}
return 0;
}