delphi产生10个100以内的随机数并将这10个随机数从小到大排序
答案:2 悬赏:0 手机版
解决时间 2021-03-08 06:07
- 提问者网友:人傍凄凉立暮秋
- 2021-03-07 09:19
delphi产生10个100以内的随机数并将这10个随机数从小到大排序
最佳答案
- 五星知识达人网友:山君与见山
- 2021-03-07 10:24
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
a:array[1..10] of 0..100;
i,j,k:integer;
begin
{ TODO -oUser -cConsole Main : Insert code here }
randomize;
for i:=1 to 10 do begin a[i]:=random(101); end;
for i:=1 to 10-1 do for j:=i+1 to 10 do
if a[i]>a[j] then begin
k:=a[i];
a[i]:=a[j];
a[j]:=k;
end;
for i:=1 to 10 do writeln(a[i]);
readln;
end.
{$APPTYPE CONSOLE}
uses
SysUtils;
var
a:array[1..10] of 0..100;
i,j,k:integer;
begin
{ TODO -oUser -cConsole Main : Insert code here }
randomize;
for i:=1 to 10 do begin a[i]:=random(101); end;
for i:=1 to 10-1 do for j:=i+1 to 10 do
if a[i]>a[j] then begin
k:=a[i];
a[i]:=a[j];
a[j]:=k;
end;
for i:=1 to 10 do writeln(a[i]);
readln;
end.
全部回答
- 1楼网友:风格不统一
- 2021-03-07 10:42
procedure tform1.button1click(sender:tobject);
var
s:string;
begin
randomize;
memo1.lines.clear;
while memo1.lines.count<5 do begin
s := inttostr(random(35)+1);
if memo1.lines.indexof(s)<0 then
memo1.lines.add(s);
end;
end;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯