#include "stdio.h" int main(void) { float c; float result=0.0; #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #else #endif while((scanf("%G",&c))!=EOF){ //printf("%Gn",c); result = result + c; //printf("%Gn",result); } printf("$%G",result/12); #ifndef ONLINE_JUDGE fclose(stdin); #else #endif return 0; }
POJ上已经定义了ONLINE_JUDGE. 所以要用"ifndef", 本地IDE中的宏定义删了. scanf: %f小数点后6位 %G和%g 小数点后2位,但是自动会去除末尾的0