如何增加中间数,小问题。(50分)

P

pzning

Unregistered / Unconfirmed
GUEST, unregistred user!
不知如何生成随机的号码,不要重复,要15位,都是大写字母。
还有就是,增加中间的数
比如说,开头是jj 我想有10位 开头从0到9999999999这数中间的数如何生成,谢谢,给例子
 
问题1
for i:=1 to 15 do
edit1.Text := edit1.Text+chr(randomrange(65,90));
 
编过不去
 
在uses 中 加上 Math
 
产生 m 个:
procedure TForm1.Button1Click(Sender: TObject);
var
c:char;
s:string;
m,x1,x2,n,i:integer;
begin
M:=10;
n:=0;
x1:=ord('A');
x2:=ord('Z');
x2:=x2-x1+1;
memo1.clear;
while n<M do
begin
s:='';
for i:=1 to 15 do
s:=s+char(Random(x2)+x1);
if memo1.Lines.indexof(s)<0 then
begin
inc(n);
memo1.lines.add(s);
end;
end;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
randomize;
showmessage(format('JJ%.10d',[random(10000000000)]));
end;
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,math;

type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
s:char;
begin
edit1.Text :=chr(randomrange(65,90));
i:=1;

while i<15 do
begin

s:=chr(randomrange(65,90));
if pos(s,edit1.Text)=0 then
begin
edit1.Text:=edit1.Text+s;
i:=i+1;
end;
end;

end;

end.
// 在uses加 math
 
i:=25;
randomize ;
for a:=0 to 15 do
edit1.Text :=chr(random(i)+65)+ edit1.Text;
 
比如说,开头是jj 我想有10位 开头从0到9999999999这数中间的数如何生成,谢谢,给例子
不明白什么意思
 
procedure TForm1.Button2Click(Sender: TObject);
begin
randomize;
showmessage(format('JJ%.10d',[random(10000000000)]));
end;
 
顶部