hdoj 2010 水仙花数
#include <stdio.h>
int main()
{
int num1, num2;
while( scanf( "%d", &num1) != EOF )
{
int i1, i2, i3, i, ret = 0;
scanf( "%d", &num2 );
for( i = num1; i <= num2; i++ )
{
i1 = i / 100;
i2 = (i / 10) % 10;
i3 = i % 10;
if( i1*i1*i1 + i2*i2*i2 + i3*i3*i3 == i )
{
printf( "%d ", i);
ret = 1;
}
}
if( ret == 0 )
printf( "no" );
printf( "\n" );
}
return 0;
}
ret = 1;
}
}
if( ret == 0 )
printf( "no" );
printf( "\n" );
scanf( "%d", &num1);
}
return 0;
}
不清楚楼1、2所说的空格指什么?
[解决办法]
#include <stdio.h>
int main()
{
int num1, num2;
while( scanf( "%d", &num1) != 0 )
{
int i1, i2, i3, i, ret = 0;
scanf( "%d", &num2 );
if(num2<num1)
continue;
for( i = num1; i <= num2; i++ )
{
i1 = i / 100;
i2 = (i / 10) % 10;
i3 = i % 10;
if( i1*i1*i1 + i2*i2*i2 + i3*i3*i3 == i )
{
printf( "%d ", i);
ret = 1;
}
}
if( ret == 0 )
printf( "no" );
printf( "\n*******\n" );
}
return 0;
}
输入:1
200
输出:1 153