Points can add enough, my operation function is as follows:
Function TFrmMain. CharCount (s, c: string) : Integer;
The begin
Result: (=Length (s) - Length (AnsiReplaceStr (s, c, "))) div (Length (c));
end;
The function TFrmMain. TestCode_IsPH (Test_Code: String) : Boolean;
The begin
If CharCount (Test_Code, '0')=CharCount (Test_Code, '1') then
Result:=True
The else
Result:=False;
end;
The function TFrmMain. TestByNum (TestCode, SourceCode: String; WS: Integer) : Boolean;
Var
Loop: Integer;
Flag: a Boolean;
The begin
Flag:=True;
For Loop:=1 to length (SourceCode) - WS + 1 do
The begin
If the Copy (SourceCode, Loop, ws)=TestCode then
The begin
Flag:=False;
Break;
end;
end;
Result:=Flag;
end;
//JZ - hexadecimal
//WS - digits
//TotalNum number
-The function TFrmMain. GetCodeByNum (MiddleCode: String; JZ, WS, TotalNum: Integer) : String;
Var
FirstCode: String;
CurrentCode: String;
Loop: Integer;
OverCode: String;
The begin
Self. StatusBar1. Panels [0]. Text:=IntToStr (StrToInt (self) StatusBar1) Panels [0]. The Text) + 1);
FirstCode:=Copy (MiddleCode, 1, Ws);
CurrentCode:=Copy (MiddleCode, length (MiddleCode) - Ws + 2, Ws - 1);
If length (MiddleCode) then=TotalNum + Ws - 1
The begin
If (CurrentCode + Copy (MiddleCode, 1, 1)=FirstCode) then
The begin
OverCode:=copy (MiddleCode, 1, length (MiddleCode) - WS + 1);
If TestCode_IsPH (OverCode) then
The begin
GoalFlag:=1;
ListBox1. Items. The Add (OverCode);
end;
end;
The Exit;
end;
Do for Loop:=0 to Jz - 1
The begin
If TestByNum (CurrentCode + IntToStr (Loop), MiddleCode, WS) then
The begin
If GoalFlag & lt;> 1 then
GetCodeByNum (MiddleCode + IntToStr (Loop), Jz, Ws, TotalNum);
end;
end;
end;
//call
Procedure TFrmMain. Button1Click (Sender: TObject);
The begin
,11,1296 GetCodeByNum (' 00000000000 ', 2)
end;
CodePudding user response:
Self. StatusBar1. Panels [0]. Text:=IntToStr (StrToInt (self) StatusBar1) Panels [0]. The Text) + 1);Application. ProcessMessages;//add this sentence, can see that the program is running.
Don't want to become a response is not available, use multithreading.
CodePudding user response:
Didn't understand this problem passing,2 base operations directly with best operations faster,,
CodePudding user response:
To track it and see if the if TestCode_IsPH (OverCode) then condition has been not satisfied, so GoalFlag to 0, all the are forever performingIf GoalFlag & lt;> 1 then
GetCodeByNum (MiddleCode + IntToStr (Loop), Jz, Ws, TotalNum);
Never jump out
CodePudding user response:
Try multithreading, or try the recursion depth decreases a little,CodePudding user response:
BDMH
(BDMH)
Level:
19
More MEDALS # 3/f score: 0 reply in: the 2011-07-16 16:15:25 tracking once, see if the if TestCode_IsPH (OverCode) then condition has been not satisfied, so GoalFlag to 0, all the are forever performing
If GoalFlag & lt;> 1 then
GetCodeByNum (MiddleCode + IntToStr (Loop), Jz, Ws, TotalNum);
Never jump out
This is not very clear, but in my set up six coding, arithmetic when I get 50 produced as a result, I now is 11 coding, if the total is 2046, I only need 1296 now, should be no problem in theory,
Now estimate is recursive too deep, can't do it, don't know the DELPHI are there any restrictions on this aspect, whether the ring c + + will have better results, but I haven't got a c + +, a little too will write,
CodePudding user response:
This problem is a little meaning, score a lotCodePudding user response:
Find an infinite loopCodePudding user response:
I a, infinite recursion, five star of the rightCodePudding user response:
If TestCode_IsPH (OverCode) sure, then can meet, when I was in less bits has acquired coding, is much more bits, a CPU resources allow only 50%, this leads to operational cannot proceed, become "no response",CodePudding user response:
[1296 2 hexadecimal data containing 0, 1]The scope of each number is how much? That is: how much they are binary bit??
CodePudding user response:
now estimate is recursive too deep, lead to can't do itA sweat
CodePudding user response:
The building Lord, I make a copy of your code, I feel your code is not your formal code, at least on the interface I don't know what its calculation result is, I guess again, add some code, judge recursive had reached 200000 times, and still not finish... , you stick you can run the DEMO on bai?CodePudding user response:
Again feel suspicious, so deep recursion, incredibly don't overflow? Strange, I am using XE, XE, a leader,CodePudding user response:
That is my formal operational use several functions, because I this design is no problem,CodePudding user response:
I recently in arithmetic of recursion, sometimes lose response, do not know to have what good method, if lose response, don't know how I can quit the recursionCodePudding user response:
With the Application. The Postmessage to receive news,Set up a sign in the message handler,
In algorithm detects a, if found that users need to stop algorithm directly exit,
In addition,
In terms of ontology, is actually will 1296/2=648 1 assigned to round into 1 turn in the 1296 grid and demanded that the arbitrary 11 grid of Numbers are not the same, right?
CodePudding user response:
The data after extended to 1296 + 11 11 and 11 before the sameCheck whether 11 times repeated, can, do not need recursive
CodePudding user response:
The data after extended to 1296 + 11 11 and 11 before the sameCheck the time 1296 times 1296 * 1296
In front of the number of wrong,
CodePudding user response:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull