第一个点为啥错了

P1898 缘分计算

>#include<iostream> ```cpp #include<cstdio> #include<cmath> using namespace std; string str; int st,a[100],l,p10[5]={1,10,100,1000,10000}; int main(){ int n=0,x,i,s,t,ps; cin>>str; cin>>st; l=str.length(); for (i=0;i<l;i++){ x=str[i]-65+st; if (x<10){ n++; a[n]=x; } else{ s=0; t=x; while (t>0){ s++; t=t/10; } while (s>0){ ps=p10[s-1]; n++; a[n]=x/ps; x=x%ps; s--; } } } ``` /\* for (i=1;i<=n;i++){ cout<<a[i]<<' '; } \*/ ```cpp //cout<<n<<endl; while (n>2){ n--; if (n==2 && a[1]==1 && a[2]==0 && a[3]==0){ cout<<"100"; return 0; } for (i=1;i<=n;i++){ //cout<<a[i]; a[i]=(a[i]+a[i+1])%10; } //cout<<a[n+1]<<endl; } cout<<a[1]<<a[2]; return 0; } ```
by WarriorWdk @ 2017-08-03 21:14:15


@[王德坤lele](/space/show?uid=20426) 答案输出时可能有前导0,应该在处理过程中去掉,并且在结果输出时做判断,也可以用string+stringstream做,很好写
by RiverHamster @ 2017-08-31 16:52:25


@ RiverHamster 谢谢,A了
by WarriorWdk @ 2017-09-03 13:19:22


@[王德坤lele](/space/show?uid=20426) 请问您是怎么改的?我改了以后RE
by wuyutong111 @ 2018-11-18 17:14:22


不用了,已A
by wuyutong111 @ 2018-11-18 17:33:52


|