请问qb大侠 求水仙花数的程序哪儿错了?
qbasic吧
全部回复
仅看楼主
level 1
for x=1 to 9for y=1 to 9for z=1 to 9if 100*x+10*y+z=x^3+y^3+z^3 then n=n+1:print x;y;z,"成立"next z,y,x在循环语句中的if语句判断错误,但这样的语句不放在循环体内则不会出错,请问qb大侠其中原因是什么?
2005年06月05日 04点06分 1
level 0
n=n+1是干什么用的
2005年06月05日 08点06分 2
level 1
for x=1 to 9for y=0 to 9for z=0 to 9if x*x*x+y*y*y+z*z*z=x*100+y*10+z then print x*100+y*10+z,"成立"next z,y,x
2005年06月18日 09点06分 3
level 0
加一个END IF
2005年11月17日 06点11分 9
level 0
三个变量不能同时运行试一下只用一个变量clsfor i= 100 to 1000if i=i mod 10 +((i\10) mod 10)^3 +(i\100)^3 then print inext iend试一下这样行不行.
2005年11月19日 11点11分 10
level 0
错了啊加一个endif不会有用啊
2005年11月23日 10点11分 11
level 0
100~999的水仙花数FOR A = 1 TO 9FOR B = 0 TO 9FOR C = 0 TO 9D=A*100+B*10+CIF A^3+B^3+C^3=D THEN PRINT DNEXT CNEXT BNEXT AEND
2005年12月13日 04点12分 12
level 0
水仙数不能用“^”比如0^0 结果等于1所以只能0*0好象是这么回事我新手
2005年12月21日 15点12分 13
level 0
dim a as integer,b as integer,c as integer,i as integerfor i = 100 to 999 a=int(i/100) b=int ((i-100*a)/10) c=i-int(i/10)*10 if =a*a*a+b*b*b+c*c*c then print i,next iprint end
2006年03月30日 04点03分 14
level 0
不能用next x,y,z要用next xnext ynext z不用想省事
2006年08月01日 02点08分 15
level 1
15楼说的对 我也是这么想的
2006年08月07日 07点08分 16
level 0
13楼新手还这么厉害
2008年04月14日 03点04分 17
level 1
13、15楼,你们说的不对,这种写法是
正确的
我试了,楼主的if语句是对的,楼主的错误可能是因为其他原因吧(比如马虎写错了)
2008年05月24日 11点05分 18
level 1
应该输入clsinput nbai=n\100shi=n mod 100\10ge=n mod 100 mod 10后面比较简单,自己去想
2008年08月11日 09点08分 19
level 1
FOR n100TO 999
i=INT(n/100)
j=INT((n-i*100)/10)
k=n MOD 10
IF i^3+j^3+k^3=n THEN PRINT n
NEXT n
END
这程序对不对????
2011年05月23日 01点05分 20
level 7
不可以用中文吧………………
2011年07月12日 06点07分 21
1