编程:求100-999之间的所有水仙花数。
3个回答
展开全部
LOCAL lnI,lcZf,lnGw,lnSw,lnBw
FOR lnI=100 to 999
lcZf=ALLTRIM(STR(m.lnI))
lnGw=VAL(SUBSTR(m.lcZf,3,1))
lnSw=VAL(SUBSTR(m.lcZf,2,1))
或者
#include<stdio.h>
void main()
{
int n = 100;
int a;
int b;
int c;
for( n=100;n<=999;n++)
{
a = n/100;
b = n/10%10;
c = n%10;
if ( n==(a*a*a+b*b*b+c*c*c))
{
printf("%d %d %d\n",a,b,c);
lnBw=VAL(SUBSTR(m.lcZf,1,1))
IF m.lnGw^3+m.lnSw^3+m.lnBw^3=m.lnI then
?m.lnI
ENDIF
ENDFOR
FOR lnI=100 to 999
lcZf=ALLTRIM(STR(m.lnI))
lnGw=VAL(SUBSTR(m.lcZf,3,1))
lnSw=VAL(SUBSTR(m.lcZf,2,1))
或者
#include<stdio.h>
void main()
{
int n = 100;
int a;
int b;
int c;
for( n=100;n<=999;n++)
{
a = n/100;
b = n/10%10;
c = n%10;
if ( n==(a*a*a+b*b*b+c*c*c))
{
printf("%d %d %d\n",a,b,c);
lnBw=VAL(SUBSTR(m.lcZf,1,1))
IF m.lnGw^3+m.lnSw^3+m.lnBw^3=m.lnI then
?m.lnI
ENDIF
ENDFOR
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询