free pascal的题目

学习 时间:2026-04-07 16:40:43 阅读:7857
free pascal的题目一个数如果只有因子2、3、5或7,那么这样的数就叫做神奇数.数据序列1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,是前20个神奇数.写程序求出数据序列的第n个神奇数输入:一个整数n(1

最佳回答

幸福的斑马

顺利的云朵

2026-04-07 16:40:43

来一个PASCAL的程序:const a:array[1。。4]of integer=(2,3,5,7);var n,m,i:integer;function humble(x:integer):boolean;var i:integer;begin humble:=true; for i:=1 to 4 do begin while x mod a[i]=0 do x:=x div a[i]; if x=1 then exit end; humble:=falseend;begin readln(n); m:=n; i:=0; while m>0 do begin inc(i); if humble(i) then dec(m); end; writeln('Then ',n,'th humble is ',i); end。

最新回答共有2条回答

  • 独特的鸡翅
    回复
    2026-04-07 16:40:43

    来一个PASCAL的程序:const a:array[1。。4]of integer=(2,3,5,7);var n,m,i:integer;function humble(x:integer):boolean;var i:integer;begin humble:=true; for i:=1 to 4 do begin while x mod a[i]=0 do x:=x div a[i]; if x=1 then exit end; humble:=falseend;begin readln(n); m:=n; i:=0; while m>0 do begin inc(i); if humble(i) then dec(m); end; writeln('Then ',n,'th humble is ',i); end。

上一篇 初中的生活我不适应!哥哥姐姐们我该怎么办啊?想个办法好么我感到压力特别大.而且我读的直升班.全是5年

下一篇 玛有什么组词?