program Project2;{$APPTYPE CONSOLE}uses SysUtils, Windows;const Max = 36; var I1, I2, I3, I4, I5, I6, I7 : Integer; Count : Integer; begin Count := 0; for I1 := 1 to Max - 6 do for I2 := I1+1 to Max - 5 do for I3 := I2+1 to Max - 4 do for I4 := I3+1 to Max - 3 do for I5 := I4+1 to Max - 2 do for I6 := I5+1 to Max - 1 do for I7 := I6+1 to Max do begin Inc(Count); { 不输出到屏幕只有300毫秒 输出到屏幕非常费时,最好不要输出.等死你啊 } //writeln(Format('%.8d: %.2d;%.2d;%.2d;%.2d;%.2d;%.2d;%.2d', // [Count, I1,I2,I3,I4,I5,I6,I7])); end; MessageBox(0,PChar(Format('共%d种组合!',[Count])),'', MB_OK or MB_ICONINFORMATION); end.
得看数字是否可以重复
SysUtils, Windows;const
Max = 36;
var
I1, I2, I3, I4, I5, I6, I7 : Integer;
Count : Integer;
begin
Count := 0;
for I1 := 1 to Max - 6 do
for I2 := I1+1 to Max - 5 do
for I3 := I2+1 to Max - 4 do
for I4 := I3+1 to Max - 3 do
for I5 := I4+1 to Max - 2 do
for I6 := I5+1 to Max - 1 do
for I7 := I6+1 to Max do
begin
Inc(Count);
{
不输出到屏幕只有300毫秒
输出到屏幕非常费时,最好不要输出.等死你啊
}
//writeln(Format('%.8d: %.2d;%.2d;%.2d;%.2d;%.2d;%.2d;%.2d',
// [Count, I1,I2,I3,I4,I5,I6,I7]));
end; MessageBox(0,PChar(Format('共%d种组合!',[Count])),'', MB_OK or MB_ICONINFORMATION);
end.