type TArr = array of array[0..1] of Byte;procedure RangeNums(arr: TArr; List: TStrings);var i,j,x,y,m,n,k,c,count: Integer;{i,j,x,y 用于循环}{m,n 分别用于前后循环的次数}{k 是从数组中取出的值}{c 是 List 的索引}{count 是 arr 的维数}begin count := Length(arr); for i := 0 to count - 1 do begin m := 1; n := 1; c := 0; {先获取 m、n} for j := 0 to count - 1 do begin if j < i then m := m * (arr[j,1] - arr[j,0] + 1); if j > i then n := n * (arr[j,1] - arr[j,0] + 1); end; {循环与排列} if i = 0 then for k := arr[i,0] to arr[i,1] do for y := 0 to n - 1 do List.Add(IntToStr(k)) else begin for x := 0 to m - 1 do for k := arr[i,0] to arr[i,1] do for y := 0 to n - 1 do begin List[c] := List[c] + IntToStr(k); Inc(c); end; end; end;end;//测试procedure TForm1.Button1Click(Sender: TObject);var arr: TArr; List: TStrings;begin SetLength(arr, 3); arr[0,0] := 2; arr[0,1] := 5; arr[1,0] := 3; arr[1,1] := 6; arr[2,0] := 1; arr[2,1] := 8; List := TStringList.Create; RangeNums(arr, List); List.SaveToFile('C:\Temp\Nums.txt'); List.Free;end;
231 232 233 234 235 236 237 238 241 242 243 244 245 246 247 248 251 252 253 254 255 256 257 258 261 262 263 264 265 266 267 268 331 332 333 334 335 336 337 338 341 342 343 344 345 346 347 348 351 352 353 354 355 356 357 358 361 362 363 364 365 366 367 368 431 432 433 434 435 436 437 438 441 442 443 444 445 446 447 448 451 452 453 454 455 456 457 458 461 462 463 464 465 466 467 468 531 532 533 534 535 536 537 538 541 542 543 544 545 546 547 548 551 552 553 554 555 556 557 558 561 562 563 564 565 566 567 568
联系客服