| ||||||||||
| 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 | |||||||||
错在哪?#include "iostream.h"
int main()
{
int n,j,a[1000],i,t,s;
a[0]=0;
a[1]=9;
a[2]=9;
j=2;
while(a[j]<900000000)
{
a[j+1]=a[j]*10;
a[j+2]=a[j]*10;
j=j+2;
}
for(i=0;i<=j;i++)
{
a[i]=a[i-1]+a[i];
}
s=j;
cin>>n;
while(n)
{
char c[10000]={0};
for(i=0;i<=s&&a[i]<n;i++);
t=n-a[i-1];
if(i==1)
{
cout<<n<<endl;
cin>>n;
continue;
}
if(i==2)
{
cout<<t<<t<<endl;
cin>>n;
continue;
}
j=(i-1)/2;
c[i]='\0';
t--;
while(t)
{
c[j]=t%10+'0';
c[i-j-1]=c[j];
t=t/10;
j--;
}
if(c[0])c[0]++;
else
c[0]=c[0]+'1';
c[i-1]=c[0];
for(j=0;j<i;j++)
{
if(!c[j])c[j]=c[j]+'0';
}
cout<<c<<endl;
cin>>n;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator