ONLINE_JUDGE
2012-01-04 17:07 Jeff 阅读(1263) 评论(0) 收藏 举报
POJ上已经定义了ONLINE_JUDGE.
所以要用"ifndef", 本地IDE中的宏定义删了.
scanf:
%f小数点后6位
%G和%g 小数点后2位,但是自动会去除末尾的0
#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;
}
浙公网安备 33010602011771号