| ||||||||||
| 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<stdio.h>
//long min(long temp[]);
int main()
{
unsigned long a[5844]={2000000000};
unsigned long temp[4],t;
a[1]=1;a[2]=2;a[3]=3;a[4]=4;
int i,n,j;
i=4;
while(i<=5842)
{
t=a[i];
for(j=1;j<=i;j++)
{
temp[0]=a[j]*2;
temp[1]=a[j]*3;
temp[2]=a[j]*5;
temp[3]=a[j]*7;
if(temp[0]>a[i])
{
if(t!=a[i]&&temp[0]<t) t=temp[0];
if(t==a[i]) t=temp[0];
}
if(temp[1]>a[i])
{
if(t!=a[i]&&temp[1]<t) t=temp[1];
if(t==a[i]) t=temp[1];
}
if(temp[2]>a[i])
{
if(t!=a[i]&&temp[2]<t) t=temp[2];
if(t==a[i]) t=temp[2];
}
if(temp[3]>a[i])
{
if(t!=a[i]&&temp[3]<t) t=temp[3];
if(t==a[i]) t=temp[3];
}
}
i++;
a[i]=t;
}
while(scanf("%d",&n)!=EOF && n>0)
{
if(n%10==1 && n%100!=11) printf("The %dst humble number is %d.\n",n,a[n]);
else if(n%10==2 && n%100!=12) printf("The %dnd humble number is %d.\n",n,a[n]);
else if(n%10==3 && n%100!=13) printf("The %drd humble number is %d.\n",n,a[n]);
else printf("The %dth humble number is %d.\n",n,a[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