几个简单的编程题目.高手进来一下.用BASIC语言.

来源:百度知道 编辑:UC知道 时间:2024/05/31 03:34:53
1.求100至200之间的全部素数。每行打印五个。

2.求所有这样的三位数,这些三位数等于它各位数字的立方和,请编写一个程序找出所有的这样三位数,并打印出来。
例如,153=13 +53 +33 。

3.将一张百元人民币换成5元、1元和0.5元面值的的零币一百张,每种不少于一张,问有哪几种组合?请编写一段程序将所有情况打印出来。

用QB软件.

1.
cls
rem c是判断是否都不能整除
for a=100 to 200
c=0
for b=2 to a-1
if a/b=int(a/b) then c=1
next b
if c=0 then
print a,
end if
next a
end

2.
cls
rem a是百位,b十位,c个位
for a=1 to 9
for b=0 to 9
for c=0 to 9
if int(a^3+b^3+c^3)=int(a*100+b*10+c) then print a*100+b*10+c,
next c
next b
next a
end

3.
cls
rem d为计数器
d=0
for a=1 to 19
for b=1 to 94
for c=1 to 188
if a*5+b+c*0.5=100 then
print "5=";a,"1=";b,"0.5=";c
d=d+1
end if
next c
next b
next a
print "Total=";d
end

1.
cls
rem c/C是判断是否都不能整除
for a=100 to 200
c=0
for b=2 to a-1
if a/b=int(a/b) then c=1
next b
if c=0 then
print a,
end if
next a
end

2.
cls
rem a是百位,b十位,c个位
for a=1 to 9
for b=0 to 9
for c=0 to 9<