Home > Back-end > The couple asked, questions about randomly
The couple asked, questions about randomly
Time:09-28
Questions about randomly, I want to do as a result of such as the extraction of the records, pulled out not draw on to the next time, such as 10 records collected 7, next time extraction of article 7, article 3 to the results have not been extracted, the other four cycle extraction, the reciprocating, I'm new everybody don't laugh at my question, thank you, prawns help, don't know how to write,,, the procedure is as follows,
Implementation
USES the Main, Extract1Rep ExtractResult;
{$R *. DFM}
//take a function and returns an array containing extraction results The function ExtractFunc (const m_count e_count: integer; Var TArray: an array of integer) : string; Var X, I: integer; St: string; The begin If e_count & lt;=0 then the exit; //if e_count & gt; M_count will appear dead cycle, so judgment and jump out of the loop If e_count & gt; M_count then The begin Application. MessageBox (' extraction number cannot be greater than the total extract. ', 'prompt', MB_OK); exit; end; I:=1; St:='; While i<=e_count do The begin Randomize. X:=the Random (m_count) + 1;//produce 1 ~ m_count random number //if the extraction to the random number x is not extract before, it is saved to the st, the comma separated If ansipos (Quotedstr (inttostr (x)) + ', ', st) & lt;=0 then The begin St:=st + Quotedstr (inttostr (x)) + ', '; TArray: [I - 1]=x; I:=I + 1; end; end; Result:=st;
end;
CodePudding user response:
Article 10 records collected 7, next time extraction of article 7, article 3 to the results have not been extracted, the other four cycle extraction of
Feel a little dizzy, such randomness can good? Idea: each record to increase the number one is extracted information Every time extraction, according to the number (trans) + random sort, extract to record, number plus one