PB求出所有的水仙花数

yakamoz702 2008-03-31 05:59:45
用PowerBuilder的MessageBox函数显示所有水仙花数的结果,并把水仙花数写入到初始化文件,并说明如何创建初始化文件,如何写入。
哪位编程高手帮个忙啊,我是一点都不懂
...全文
325 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
谁是谁的谁 2008-05-04
这个版块MS很冷清啊.
回复
关注 接分
回复
skyzcl 2008-04-01
Description

Writes a value in a profile file for a PowerBuilder application.

Syntax

SetProfileString ( filename, section, key, value )

Argument Description
filename A string whose value is the name of the profile file. If you do not include the full path in filename, PowerBuilder searches the DOS path for filename.
section A string whose value is the name of a group of related values in the profile file. If section does not exist in the file, PowerBuilder adds it.
key A string whose value is the key in section for which you want to specify a value. If key does not exist in section, PowerBuilder adds it.
value A string whose value is the value you want to specify for key.
Return value

Integer. Returns 1 when it succeeds and -1 if it fails because filename is not found or cannot be accessed. If any argument's value is null, SetProfileString returns null.

按F1查帮助
回复
jlwei888 2008-04-01
都是基本知识!

setprofilestring()写入初始化文件指定项的值
要先创建c:\xxx.ini文件
setporfilestring('c:\xxx.ini','data','name','server')//c:\xxx.ini的节data 的键值 name 值 设为server

profilestring()读取初始化文件指定项的值

回复
SKY_4K_PPM 2008-04-01
INTEGER LI_NUMBER,LI_3W,LI_2W,LI_1W
STRING LS_NUMBER,LS_SHXN
FOR LI_NUMBER=100 TO 999
LI_3W=LI_NUMBER/100
LI_2W=MOD((LI_NUMBER/10),10)
LI_1W=MOD(LI_NUMBER,10)
IF LI_NUMBER<>LI_3W^3 +LI_2W^3 +LI_1W^3 THEN
CONTINUE;
ELSE
LS_NUMBER=STRING(LI_NUMBER)
LS_SHXN+=LS_NUMBER+'/'
END IF
END FOR
MESSAGEBOX('',LS_SHXN)
然后建立一个 完整路径+水仙.TEXT,设立一个 [水仙花数]段,"水仙数字:"
用SETPROFILESTRING("水仙.TEXT","水仙花数","水仙数字",LS_SHXN)

回复
yakamoz702 2008-03-31
例如153,即为一水仙花数,153=1^3+5^3+3^3
回复
yakamoz702 2008-03-31
水仙花数是指一个三位数,其各个数之立方和等于该数,例如153,即为一水仙花数,因为153=13+53+33

程序应该是
integer i,a,b,c
for i=100 to 999
a=integer(i/100)
b=integer((i-100*a)/10)
c=i-integer(i/10)*10
if i=a*a*a+b*b*b+c*c*c then
messagebox("","i")
end if
next

关键问题是不晓得如何把水仙花数写入到初始化文件,如何创建初始化文件,帮个忙啊
回复
eviler 2008-03-31
说实话,我现在不知道水仙花是什么
回复
jlwei888 2008-03-31
看书吧!
回复
相关推荐
发帖
PowerBuilder
创建于2007-09-28

866

社区成员

PowerBuilder 相关问题讨论
申请成为版主
帖子事件
创建了帖子
2008-03-31 05:59
社区公告
暂无公告