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 |
我编的程序为什么总在VC可运行,却在poj上WA#include<iostream> #include<string> using std::string; using std::cin; using std::cout; int a[105]={0}; void f(int v) { a[v]++; if(a[v]>=10) { a[v]=a[v]%10; v++; f(v); } } void add(char *p) { int w=0,u=0,u1=0; u1=strlen(p)-1; while(u!=strlen(p)) { w=int(p[u1]-'0'); a[u]=w+a[u]; if(a[u]>=10) { a[u]=a[u]%10; f(u+1); } u++; u1--; } } int main() { int j=0,j1=0,y=105; char l[200],*p="0"; cin>>l; j=strlen(l)-1; while(j!=-1) { a[j1]=int(l[j]-'0'); j--; j1++; } while(strcmp(p,l)!=0) { cin>>l; add(l); } while(a[y]==0) { --y; } for(int s=y;s>=0;s--) { cout<<a[s]; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator