//你已经基本完成了,很好 function Calc(mStrings: TStrings): Real; var I, J: Integer; begin Result := 0; for I := 0 to mStrings.Count - 1 do for J := 1 to Length(mStrings[I]) do if mStrings[I][J] in ['0'..'9'] then begin Result := Result + StrToFloat(Copy(mStrings[I], J, Length(mStrings[I]))); Break; end; end;procedure TForm1.Button1Click(Sender: TObject); begin Caption := FloatToStr(Calc(Memo1.Lines)); end;
to zswang(伴水)(被黑中) //cry//cry//cry//cry//cry俺以为被师傅开除了 眼睛哭成核桃了 嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿 嘿嘿嘿师傅快乐嘿嘿嘿嘿嘿 嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿师傅,俺的QQ不好用,等俺好用了在加侬 俺记下EMAIL了,注意查收贺卡喽~~~~~~~~~
//对比一下区别 function Calc(mStrings: TStrings): Real; var I, J: Integer; begin Result := 0; for I := 0 to mStrings.Count - 1 do for J := Length(mStrings[I]) downto 1 do if not (mStrings[I][J] in ['0'..'9', '.', '+', '-']) then begin Result := Result + StrToFloatDef(Copy(mStrings[I], J + 1, MaxInt), 0); Break; end; end;//用如下数据测试 a1=10.2 a2=32.0 a3=52.0 a4=31.2StrToFloatDef() 和 StrToIntDef() 相似 StrToFloatDef是Delphi6才有//你如果用Delphi5就加下面代码 function StrToFloatDef(mStr: string; mDefault: Real): Real; var vCode: Integer; begin Val(mStr, Result, vCode); if vCode <> 0 then Result := mDefault; end;//程序是从至下识别的 procedure a; begin //不可以调用b end;procedure b; begin //可以调用a end;
to zswang(伴水)(被黑中) 师傅,侬在忙什么? 是不是特后悔收了俺这个笨笨徒弟啊? 侬想开除俺就直接说 俺懒,可是不赖皮,哼 //inn//kick//cry
//程序是从至下识别的 procedure a; begin //不可以调用b end;procedure b; begin //可以调用a end;要是都声明了,象我的加个窗体名字,不就是可以调用了吗? 俺去试试师傅的程序,嘿嘿 //sorry//thank/shy/inn//hand//milk
function StrToFloatDef(mStr: string; mDefault: Real): Real; var vCode: Integer; begin Val(mStr, Result, vCode); if vCode <> 0 then Result := mDefault; end; function Calc(mStrings: TStrings): Real; var I, J: Integer; begin Result := 0; for I := 0 to mStrings.Count - 1 do for J := Length(mStrings[I]) downto 1 do if not (mStrings[I][J] in ['0'..'9', '.', '+', '-']) then begin //师傅,你这里和俺的判断不一样,为什么? //你是判断不属于数字里的,为什么不是'.', '+', '-'也判断? //为什么结果也是加啊累计啊?俺以为是出现字符那,嘿嘿 Result := Result + StrToFloatDef(Copy(mStrings[I], J + 1, MaxInt), 0); Break; end; end;procedure TForm1.Button1Click(Sender: TObject); begin Caption := FloatToStr(Calc(Memo1.Lines));//测试通过~~~~~~~~~~~嘿嘿 end;
function Calc(mStrings: TStrings): Real; var I, J: Integer; begin Result := 0; for I := 0 to mStrings.Count - 1 do for J := Length(mStrings[I]) downto 1 do // ~~~~~~我是从后面开始判断 if not (mStrings[I][J] in ['0'..'9', '.', '+', '-']) then begin //分析以下情况: //No.1 = 12 //你的方法就会取得 '1 = 12' //多一个“1 = ” //-1.12 //你的方法就会取得 '1.12' //少一个符号“-” Result := Result + StrToFloatDef(Copy(mStrings[I], J + 1, MaxInt), 0); // ~~~~~~你怎么忘了? Break; end; end;
Result := Result + StrToFloatDef(Copy(mStrings[I], J + 1, MaxInt), 0); // ~~~~~~你怎么忘了?1,这个俺记得,也想用不用MaxInt,可是我想不如用具体的长度好,MaxInt要取很多位啊? 是不是?后面的添空格吧?嘿嘿for J := Length(mStrings[I]) downto 1 do // ~~~~~~我是从后面开始判断 if not (mStrings[I][J] in ['0'..'9', '.', '+', '-']) then begin师傅俺这里也明白了,俺刚才知道是down的,但是忘记了对这个问题从后象前就是 要先找到数字,是吗?2,对了师傅,我看你把我两个begin去掉了,在for,,,do 下面有很多语句时不 begin end; 可以吗?3,师傅,你说你周末周日在网吧上网,那平时的子夜那?嘿嘿
//thank//tea//milk//@@to kevin_gao(困了!累了!睡觉了!) //hammer//ice//zap//pinch//bug
嘻嘻嘻新年快乐嘻嘻嘻嘻
嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻mailto:[email protected]
oicq:45531143
function Calc(mStrings: TStrings): Real;
var
I, J: Integer;
begin
Result := 0;
for I := 0 to mStrings.Count - 1 do
for J := 1 to Length(mStrings[I]) do
if mStrings[I][J] in ['0'..'9'] then begin
Result := Result + StrToFloat(Copy(mStrings[I], J, Length(mStrings[I])));
Break;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := FloatToStr(Calc(Memo1.Lines));
end;
//cry//cry//cry//cry//cry俺以为被师傅开除了
眼睛哭成核桃了
嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿
嘿嘿嘿师傅快乐嘿嘿嘿嘿嘿
嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿嘿师傅,俺的QQ不好用,等俺好用了在加侬
俺记下EMAIL了,注意查收贺卡喽~~~~~~~~~
function Calc(mStrings: TStrings): Real;
var
I, J: Integer;
begin
Result := 0;
for I := 0 to mStrings.Count - 1 do
for J := Length(mStrings[I]) downto 1 do
if not (mStrings[I][J] in ['0'..'9', '.', '+', '-']) then begin
Result := Result + StrToFloatDef(Copy(mStrings[I], J + 1, MaxInt), 0);
Break;
end;
end;//用如下数据测试
a1=10.2
a2=32.0
a3=52.0
a4=31.2StrToFloatDef() 和 StrToIntDef() 相似
StrToFloatDef是Delphi6才有//你如果用Delphi5就加下面代码
function StrToFloatDef(mStr: string; mDefault: Real): Real;
var
vCode: Integer;
begin
Val(mStr, Result, vCode);
if vCode <> 0 then Result := mDefault;
end;//程序是从至下识别的
procedure a;
begin
//不可以调用b
end;procedure b;
begin
//可以调用a
end;
是不是特后悔收了俺这个笨笨徒弟啊?
侬想开除俺就直接说
俺懒,可是不赖皮,哼
//inn//kick//cry
procedure a;
begin
//不可以调用b
end;procedure b;
begin
//可以调用a
end;要是都声明了,象我的加个窗体名字,不就是可以调用了吗?
俺去试试师傅的程序,嘿嘿
//sorry//thank/shy/inn//hand//milk
var
vCode: Integer;
begin
Val(mStr, Result, vCode);
if vCode <> 0 then Result := mDefault;
end;
function Calc(mStrings: TStrings): Real;
var
I, J: Integer;
begin
Result := 0;
for I := 0 to mStrings.Count - 1 do
for J := Length(mStrings[I]) downto 1 do
if not (mStrings[I][J] in ['0'..'9', '.', '+', '-']) then begin
//师傅,你这里和俺的判断不一样,为什么?
//你是判断不属于数字里的,为什么不是'.', '+', '-'也判断?
//为什么结果也是加啊累计啊?俺以为是出现字符那,嘿嘿
Result := Result + StrToFloatDef(Copy(mStrings[I], J + 1, MaxInt), 0);
Break;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := FloatToStr(Calc(Memo1.Lines));//测试通过~~~~~~~~~~~嘿嘿
end;
嘻嘻嘻新年快乐嘻嘻嘻嘻
嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻怎么说自己笨呢?很高兴和你交流
一直都在给你出题
也没仔细给你说明
不要怪我
很多时候要自己理解
而且很多东西你也能够理解周六周日很少上网,要上都只在网吧,手里没有Delphi不能给你调试
var
I, J: Integer;
begin
Result := 0;
for I := 0 to mStrings.Count - 1 do
for J := Length(mStrings[I]) downto 1 do
// ~~~~~~我是从后面开始判断
if not (mStrings[I][J] in ['0'..'9', '.', '+', '-']) then begin
//分析以下情况:
//No.1 = 12 //你的方法就会取得 '1 = 12' //多一个“1 = ”
//-1.12 //你的方法就会取得 '1.12' //少一个符号“-”
Result := Result + StrToFloatDef(Copy(mStrings[I], J + 1, MaxInt), 0);
// ~~~~~~你怎么忘了?
Break;
end;
end;
一直都在给你出题 //这个俺知道,知道师傅是认真的人,俺也是
也没仔细给你说明 //不说明俺糊涂,嘿嘿
不要怪我 //不理俺说不怪,那是假的,呜呜
很多时候要自己理解 //这个俺知道,可是要有一定的基础以后,想告诉俺都不要那,嘿嘿,
而且很多东西你也能够理解 //现在还不可以,但是要看师傅了,俗话曰:拉拉拉拉,师傅明白还有,我刚发了MAIL,师傅接到没?我也是测试一下信箱是不是正确,嘿嘿
// ~~~~~~你怎么忘了?1,这个俺记得,也想用不用MaxInt,可是我想不如用具体的长度好,MaxInt要取很多位啊?
是不是?后面的添空格吧?嘿嘿for J := Length(mStrings[I]) downto 1 do
// ~~~~~~我是从后面开始判断
if not (mStrings[I][J] in ['0'..'9', '.', '+', '-']) then begin师傅俺这里也明白了,俺刚才知道是down的,但是忘记了对这个问题从后象前就是
要先找到数字,是吗?2,对了师傅,我看你把我两个begin去掉了,在for,,,do 下面有很多语句时不
begin
end;
可以吗?3,师傅,你说你周末周日在网吧上网,那平时的子夜那?嘿嘿
用MaxInt和Length()都会得到相同的结果,但取常量的时间比取函数的时间快No.2 只有一条语句,begin..end就可以省略//其实加上会更合理//这里不要求你//但你要看得明白
最后一条语句,“;”也可以省略//其实加上会更合理//这里不要求你//但你要看得明白No.3 我周一到周五在另一个地方呆
想来聊天室里吗?
我在做表情玩那
想来我给侬地址?
@@@@@@@@@@@@@@@@@@@@@
知道了师傅,,
1分,就这样了俺要下了,来看看师傅
嘿嘿,俺会拍师傅吧?
俺走了,别忘了责任啊
@@@@@@@@@@@@@@@@@@@@@
//用马步走法跳过所有的棋盘,不能重复unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}(*
[01],[06],[09],[26],[03],[36]
[08],[27],[02],[05],[10],[25]
[31],[16],[07],[12],[35],[04]
[28],[21],[30],[17],[24],[11]
[15],[32],[19],[22],[13],[34]
[20],[29],[14],[33],[18],[23]
*)const
cWidth = 6; //棋盘宽度
cHeight = 6; //棋盘高度const
(*
-2 -1 0 +1 +2
-2[0][2][0][3][0]
-1[1][0][0][0][4]
0[0][0][X][0][0]
+1[8][0][0][0][5]
+2[0][7][0][6][0]
*)
// 1 2 3 4 5 6 7 8
cMoveX: array[1..8] of Integer = (-2, -1, +1, +2, +2, +1, -1, -2);
cMoveY: array[1..8] of Integer = (-1, -2, -2, -1, +1, +2, +2, +1);var
vPointList: array[1..cWidth, 1..cHeight] of Integer; //棋盘procedure Print(mStrings: TStrings);
var
I, J: Integer;
S: string;
begin
mStrings.Clear;
for J := 1 to cHeight do begin
S := '';
for I := 1 to cWidth do
S := Format('%s,[%.2d]', [S, vPointList[I, J]]);
Delete(S, 1, 1);
mStrings.Add(S);
end;
end;function Calc(mStep: Integer; mX, mY: Integer): Boolean;
{ 测试下一步是否可以成功 }
var
I: Integer;
begin
Result := False;
if mStep > cWidth * cHeight then begin //步数已经走完
Result := True;
Exit;
end;
if not (mX in [1..cWidth]) then Exit;
if not (mY in [1..cHeight]) then Exit;
if vPointList[mX, mY] <> 0 then Exit; //已经走过
vPointList[mX, mY] := mStep; //走
for I := 1 to 8 do begin
Result := Calc(mStep + 1, mX + cMoveX[I], mY + cMoveY[I]); //测试下一步
if Result then Exit;
end;
vPointList[mX, mY] := 0; //退
end;procedure TForm1.Button1Click(Sender: TObject);
begin
FillChar(vPointList, SizeOf(vPointList), 0); //清零
if Calc(1, 1, 1) then Unit1.Print(Memo1.Lines);
end;end.
//cry
嘿嘿,欢迎~~~~~~是假的,嘿嘿