求一算法!(50分)

  • 主题发起人 主题发起人 marhoo
  • 开始时间 开始时间
M

marhoo

Unregistered / Unconfirmed
GUEST, unregistred user!
A(i=1,2,3,4,5,6)分别是六个未知的百分数,a[1]+a[2]+a[3]+a[4]+a[5]+a[6]=1输出可能的A[],
a计算中的步长用5%即可,就是
算a[]=1,0,0,0,0,0不成立,则计算0.95 , 0.05 ,0,0,0,0 然后计算0.95 ,0, 0.05,0,0,0
 
共计53130种:
mb:array [0..5] of byte;
mi:integer;
a:array [0..5] of real;
implementation
{$R *.dfm}
procedure sreport;
var s:byte;
begin
inc(mi);
for s:=0 to 5do
A:=mb*0.05;
// add your codes
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
mb[0]:=20;
mi:=0;
sreport;
repeat
dec(mb[0]);
mb[1]:=20-mb[0];
mb[2]:=0;
mb[3]:=0;
mb[4]:=0;
mb[5]:=0;
sreport;
repeat
dec(mb[1]);
mb[2]:=20-mb[0]-mb[1];
mb[3]:=0;
mb[4]:=0;
mb[5]:=0;
sreport;
repeat
dec(mb[2]);
mb[3]:=20-mb[0]-mb[1]-mb[2];
mb[4]:=0;
mb[5]:=0;
sreport;
repeat
dec(mb[3]);
mb[4]:=20-mb[0]-mb[1]-mb[2]-mb[3];
mb[5]:=0;
sreport;
repeat
dec(mb[4]);
inc(mb[5]);
sreport;
until mb[4]=0;
until mb[3]=0;
until mb[2]=0;
until mb[1]=0;
until mb[0]=0;
end;
 
接受答案了.
 
后退
顶部