| ||||||||||
| 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 | |||||||||
WA无数次了……大侠帮帮忙吧!!……#include <iostream.h>
#include <stdlib.h>
int compare(const void *arg1, const void *arg2)
{
if( *((int*)arg1) < *((int*)arg2) )
return -1;
else if( *((int*)arg1) == *((int*)arg2) )
return 0;
else return 1;
}
void main()
{
__int64 i, j, k, l;
int humble[5842], count;
for( i = 1, count = 0; i <= 2000000000; i *= 2 )
{
if( i > 2000000000 )
break;
for( j = i; j <= 2000000000; j *= 3 )
{
if( j > 2000000000 )
break;
for( k = j; k <= 2000000000; k *= 5 )
{
if( k > 2000000000 )
break;
for( l = k; l <= 2000000000; l *= 7 )
{
if( l > 2000000000 )
break;
humble[count] = int(l);
count ++;
}
}
}
}
qsort(humble, count, sizeof(int), compare);
int n;
cin >> n;
while( n != 0 )
{
cout << "The " << n;
if( n % 10 == 1 && n != 11 )
cout << "st humble number is " << humble[n - 1] << '.' << endl;
else if( n % 10 == 2 && n != 12 )
cout << "nd humble number is " << humble[n - 1] << '.' << endl;
else if( n % 10 == 3 && n != 13 )
cout << "rd humble number is " << humble[n - 1] << '.' << endl;
else
cout << "th humble number is " << humble[n - 1] << '.' << endl;
cin >> n;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator