题解 | #Grading#
Grading
http://www.nowcoder.com/practice/23e3244406724ffa8330760f640c8149
#include<stdio.h> #include<math.h> int main() { int P,T,G1,G2,G3,GJ,a,b,c; float grade; while(scanf("%d %d %d %d %d %d",&P,&T,&G1,&G2,&G3,&GJ)!=EOF) { a=abs(G1-G2); b=abs(G1-G3); c=abs(G2-G3); if(a<=T) grade=(float)(G1+G2)/2; else { if(b<=T&&c<=T) { if(G1<G2) G1=G2; if(G1<G3) G1=G3; grade=(float)G1; } if(b>T&&c>T) grade=(float)GJ; if(b<=T) grade=(float)(G1+G3)/2; if(c<=T) grade=(float)(G2+G3)/2; } printf("%.1f\n",grade); } return 0; }