Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
选择c和gcc,结果不一样下面这段程序,选择c编译AC,选择gcc编译Wrong Answer。估计问题应该是在库函数上,不知道用的gcc是什么版本的。 #include <stdio.h> #include <string.h> #include <stdlib.h> #define INPUT_MAX_NUM 12 int get_input_value(double *value) { #if 0 double input; char s[100] = {0}; char *endptr; scanf("%s", s); input = strtod(s, &endptr); if (endptr != s + strlen(s)) { return -1; } *value = input; #else scanf("%lf", value); #endif return 0; } int main(void) { int input_num = 0; double input = 0.0; double average = 0.0; while (input_num != INPUT_MAX_NUM) { if (get_input_value(&input) < 0) { continue; } input_num++; average += input; } printf("$%.2lf\n", average / input_num); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator