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 |
为什么我这代码只能过G++, C++过不了?#include <iostream> #include<cstdio> #include<cstring> using namespace std; int main() { int i, len, S; char Int[100], c, sum[102]; memset(sum, '0', sizeof(sum)); memset(Int, '\0', sizeof(Int)); while (cin >> Int && strcmp(Int, "0")) { // 加法 S = 0; len = strlen(Int); for (i = len - 1; i >= 0; i--) { S += Int[i] + sum[i + 102 - len]; if (S > 9 + 96) { sum[i + 102 - len] = S - 10 - 48; S = 1; } else { sum[i + 102 - len] = S - 48; S = 0; } } // 计算sum进位 i = i + 102 - len; while (S == 1) { sum[i]++; if (sum[i] > 48 + 9) { sum[i] -= 10; S = 1; } else S = 0; i--; } memset(Int, '\0', sizeof(Int)); } // 输出 for (i = 0; i < 102; i++) { if (sum[i] != '0') break; } if (i == 102) cout << 0 << endl; while (i < 102) { cout << sum[i]; i++; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator