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 |
哪位大哥帮忙看下有什么问题,怎么就是WA呢……#include <iostream> #include <string> using namespace std; int main() { int arr[110] = { 0 }; string str; int i; int max = 0; while ( true ) { cin>>str; if ( str[0] == '0' ) break; if ( max < str.length() ) max = str.length(); for ( i=str.length()-1; i>=0; i-- ) { arr[str.length()-1-i] += static_cast<int>((str[i])-'0'); } } for ( i=0; i<max-1; i++ ) { arr[i+1] += arr[i]/10; arr[i] %= 10; } for ( i=max-1; i>=0; i-- ) cout<<arr[i]; cout<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator