期 数 号码
2008028 473
2008029 803
2008030 371
2008031 436
2008032 0411、求每期号码最大值与最小值的差值.如2008028期的为7-3=4;
2、求3(371里面百位3),现在有多少期没出来?实际为2期;
3、求4(473里面百位4),间隔的最长期数为3期;
2008028 473
2008029 803
2008030 371
2008031 436
2008032 0411、求每期号码最大值与最小值的差值.如2008028期的为7-3=4;
2、求3(371里面百位3),现在有多少期没出来?实际为2期;
3、求4(473里面百位4),间隔的最长期数为3期;
Codes:array[0..2] of Byte;
bMax,bMin:Byte;
str:='473';
Codes[0]:=Ord(str[1]);
Codes[1]:=Ord(str[2]);
Codes[2]:=Ord(str[3]);
bMax:=Codes[0];
bMin:=Codes[0];
for i:=1 to 2 do
begin
bMax:=Max(bMax,Codes[i]);
bMin:=Min(bMin,Codes[i]);
end;
Result:=bMax-bMin;2、循环判断Codes[0]里有多少次没出现3。
strs:TStringList;//strs中加入473,803,371,436,041....
iCnt:integer;
str:string; for i:=strs.Count-1 downto 0 do
begin
str:=strs.Items[i];
if str[1]='3' then
break;
inc(iCnt);
end;
////////iCnt就是。3、 strs:TStringList;//strs中加入473,803,371,436,041....
iCnt,iMaxCnt:integer;
str:string;
bFind:boolean; iMaxCnt:=0;
bFind:=false;
for i:=0 to strs.Count-1 do
begin
str:=strs.Items[i];
if str[1]='4' then
begin
if bFind then
begin
iMaxCnt:=max(iMaxCnt,iCnt);
iCnt:=0;
bfind:=false;
end else
bFind:=true;
end;
if bFind then
inc(iCnt);
end;
////////iMaxCnt就是。
我想补充的问题是:求0,1,2,3,4,5,6,7,8,9(3位数据里面的百位),同时分别求出,现在有多少期没出来?
实际:0为0期,1为5期,2为5期,3为2期,,,,,,,,,,,
strs:TStringList;//strs中加入473,803,371,436,041....
iCnt:integer;
str:string; iCnt:=0;
for i:=strs.Count-1 downto 0 do
begin
str:=strs.Items[i];
if str[1]='3' then
break;
inc(iCnt);
end;
////////iCnt就是。 循环十次就可以了。每次判断的是0,1,2,3,4,5,........
strs:TStringList;//strs中加入473,803,371,436,041....
iCnt:integer;
str:string; iCnt:=0;
for i:=strs.Count-1 downto 0 do
begin
str:=strs.Items[i];
if str[1]='0' then break;
inc(iCnt);
end;
////////iCnt就是。 strs:TStringList;//strs中加入473,803,371,436,041....
iCnt:integer;
str:string; iCnt:=0;
for i:=strs.Count-1 downto 0 do
begin
str:=strs.Items[i];
if str[1]='1' then break;
inc(iCnt);
end;
////////iCnt就是。 ......