|
|
back to boardThe same code, different compilers This is my code. I got WA 1 on G++ and G++11, but AC on Visual C++ 2010. Why? #include <iostream> const int M = 1000*1000+1; char a[M], b[M]; int n; using namespace std; void read() { ios_base::sync_with_stdio(0); cin >> n; for(int i = n-1; i >= 0; --i) { cin >> a[i] >> b[i]; a[i] -= 48; b[i] -= 48; } } void solve() { for(int i = 0; i < n; ++i) { a[i] += b[i]; if(a[i] > 9) { a[i + 1]++; a[i] -= 10; } } } void print() { for(int i = n-1; i >= 0; --i) { cout << (int)a[i]; } } int main() { read(); solve(); print(); } |
|
|