| ||||||||||
| 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 | |||||||||
Re:请各位大牛帮我看看1503题的代码,测试好象没什么问题但总是WRONG ANSWER!!!谢谢^_^In Reply To:Re:请各位大牛帮我看看1503题的代码,测试好象没什么问题但总是WRONG ANSWER!!!谢谢^_^ Posted by:fjctlzy at 2006-03-16 21:00:18 不好意思,您能不能再解释一下,为什么以前的那个不行呢? 我觉得sum[k]好象不会>19 再次感谢!!!
> #include<iostream.h>
> #include<string.h>
> char VeryLongInteger[101];
> char temp[101];
> int sum[103];
> void main()
> {
> int i,j,k,m;
> cin>>temp;
> while(strcmp(temp,"0"))
> {
> for(i=0;temp[i]!='\0';i++);
> for(j=i-1;j>=0;j--)
> VeryLongInteger[i-1-j]=temp[j];
> for(k=0;k<i;k++)
> sum[k]+=VeryLongInteger[k]-'0';
> for(k=0;k<103;k++)
> {
> if(sum[k]>9)
> {
> sum[k+1]=sum[k+1]+sum[k]/10;//change the code here
> sum[k]=sum[k]%10;//change the code here
> }
> }
> for(k=102;k>=0;k--)
> {
> if(sum[k]!=0)
> break;
> }
> cin>>temp;
> }
> for(m=k;m>=0;m--)
> cout<<sum[m];
> cout<<endl;
> }
>
>
>
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator