Advertisement
Guest User

Untitled

a guest
Feb 7th, 2023
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 21.21 KB | None | 0 0
  1. program project2;
  2.  
  3. const
  4.   KapacitaPrvku: array [1..48] of real = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 33.1, 33.2, 33.3, 34.4, 34.5, 34.6, 34.7, 34.8, 34.9, 35, 35.1, 35.2, 35.3, 35.4, 35.5);
  5.  
  6. var
  7.   A01: array [1..36] of integer;
  8.   A02: array [1..33] of integer;
  9.   A03: array [1..30] of integer;
  10.   A04: array [1..27] of integer;
  11.   A05: array [1..24] of integer;
  12.   A06: array [1..21] of integer;
  13.   A07: array [1..18] of integer;
  14.   A08: array [1..15] of integer;
  15.   A09, B: array [1..12] of integer;
  16.   A10: array [1..9] of integer;
  17.   A11: array [1..6] of integer;
  18.   A12: array [1..3] of integer;
  19.   A: array [1..12, 1..4] of integer;
  20.   S: array [1..12] of real;
  21.   B1, B2, B3, B5, B6, B7, B9, B10, B11, B13, B14, B15, B17, B18, B19, B21, B22, B23, B25, B26, B27, B29, B30, B31, B33, B34, B35, B37, B38, B39, B41, B42, B43: integer;
  22.   MIN, MAX, DELTA, MINDELTA: real;
  23.   I, J, K, n: integer;
  24.  
  25. begin
  26.   MINDELTA := 999;
  27.   n := 48;
  28.   J := 1;
  29.   K := 1;
  30.   for I := 1 to n do
  31.     if KapacitaPrvku[I] < 34 then
  32.       begin
  33.         A01[J] := I;
  34.         J := J + 1
  35.       end
  36.     else
  37.       begin
  38.         B[K] := I;
  39.         K := K + 1;
  40.       end;
  41.   //n := 36;
  42.   for B1 := A01[3] to 36 do
  43.     for B2 := A01[2] to B1 - 1 do
  44.       for B3 := A01[1] to B2 - 1 do
  45.         begin
  46.           J := 1;
  47.           for I := 1 to 36 do
  48.             if (B1 <> A01[I]) and (B2 <> A01[I]) and (B3 <> A01[I]) then
  49.               begin
  50.                 A02[J] := A01[I];
  51.                 J := J + 1
  52.               end ;
  53.           //n := 33;
  54.           for B5 := A02[3] to 33 do
  55.             for B6 := A02[2] to B5 - 1 do
  56.               for B7 := A02[1] to B6 - 1 do
  57.                 begin
  58.                   J := 1;
  59.                   for I := 1 to 33 do
  60.                     if (B5 <> A02[I]) and (B6 <> A02[I]) and (B7 <> A02[I]) then
  61.                       begin
  62.                         A03[J] := A02[I];
  63.                         J := J + 1
  64.                       end ;
  65.                   //n := 30;
  66.                   for B9 := A03[3] to 30 do
  67.                     for B10 := A03[2] to B9 - 1 do
  68.                       for B11 := A03[1] to B10 - 1 do
  69.                         begin
  70.                           J := 1;
  71.                           for I := 1 to 30 do
  72.                             if (B9 <> A03[I]) and (B10 <> A03[I]) and (B11 <> A03[I]) then
  73.                               begin
  74.                                 A04[J] := A03[I];
  75.                                 J := J + 1
  76.                               end ;
  77.                           //n := 27;
  78.                           for B13 := A04[3] to 27 do
  79.                             for B14 := A04[2] to B13 - 1 do
  80.                               for B15 := A04[1] to B14 - 1 do
  81.                                 begin
  82.                                   J := 1;
  83.                                   for I := 1 to 27 do
  84.                                     if (B13 <> A04[I]) and (B14 <> A04[I]) and (B15 <> A04[I]) then
  85.                                       begin
  86.                                         A05[J] := A04[I];
  87.                                         J := J + 1
  88.                                       end ;
  89.                                   write('.');
  90.                                   //n := 24;
  91.                                   for B17 := A05[3] to 24 do
  92.                                     for B18 := A05[2] to B17 - 1 do
  93.                                       for B19 := A05[1] to B18 - 1 do
  94.                                         begin
  95.                                           J := 1;
  96.                                           for I := 1 to 24 do
  97.                                             if (B17 <> A05[I]) and (B18 <> A05[I]) and (B19 <> A05[I]) then
  98.                                               begin
  99.                                                 A06[J] := A05[I];
  100.                                                 J := J + 1
  101.                                               end ;
  102.                                           //n := 21;
  103.                                           for B21 := A06[3] to 21 do
  104.                                             for B22 := A06[2] to B21 - 1 do
  105.                                               for B23 := A06[1] to B22 - 1 do
  106.                                                 begin
  107.                                                   J := 1;
  108.                                                   for I := 1 to 21 do
  109.                                                     if (B21 <> A06[I]) and (B22 <> A06[I]) and (B23 <> A06[I]) then
  110.                                                       begin
  111.                                                         A07[J] := A06[I];
  112.                                                         J := J + 1
  113.                                                       end ;
  114.                                                   //n := 18;
  115.                                                   for B25 := A07[3] to 18 do
  116.                                                     for B26 := A07[2] to B25 - 1 do
  117.                                                       for B27 := A07[1] to B26 - 1 do
  118.                                                         begin
  119.                                                           J := 1;
  120.                                                           for I := 1 to 18 do
  121.                                                             if (B25 <> A07[I]) and (B26 <> A07[I]) and (B27 <> A07[I]) then
  122.                                                               begin
  123.                                                                 A08[J] := A07[I];
  124.                                                                 J := J + 1
  125.                                                               end ;
  126.                                                           //n := 15;
  127.                                                           for B29 := A08[3] to 15 do
  128.                                                             for B30 := A08[2] to B29 - 1 do
  129.                                                               for B31 := A08[1] to B30 - 1 do
  130.                                                                 begin
  131.                                                                   J := 1;
  132.                                                                   for I := 1 to 15 do
  133.                                                                     if (B29 <> A08[I]) and (B30 <> A08[I]) and (B31 <> A08[I]) then
  134.                                                                       begin
  135.                                                                         A09[J] := A08[I];
  136.                                                                         J := J + 1
  137.                                                                       end ;
  138.                                                                   //n := 12;
  139.                                                                   for B33 := A09[3] to 12 do
  140.                                                                     for B34 := A09[2] to B33 - 1 do
  141.                                                                       for B35 := A09[1] to B34 - 1 do
  142.                                                                         begin
  143.                                                                           J := 1;
  144.                                                                           for I := 1 to 12 do
  145.                                                                             if (B33 <> A09[I]) and (B34 <> A09[I]) and (B35 <> A09[I]) then
  146.                                                                               begin
  147.                                                                                 A10[J] := A09[I];
  148.                                                                                 J := J + 1
  149.                                                                               end ;
  150.                                                                           //n := 9;
  151.                                                                           for B37 := A10[3] to 9 do
  152.                                                                             for B38 := A10[2] to B37 - 1 do
  153.                                                                               for B39 := A10[1] to B38 - 1 do
  154.                                                                                 begin
  155.                                                                                   J := 1;
  156.                                                                                   for I := 1 to 9 do
  157.                                                                                     if (B37 <> A10[I]) and (B38 <> A10[I]) and (B39 <> A10[I]) then
  158.                                                                                       begin
  159.                                                                                         A11[J] := A10[I];
  160.                                                                                         J := J + 1
  161.                                                                                       end ;
  162.                                                                                   //n := 6;
  163.                                                                                   for B41 := A11[3] to 6 do
  164.                                                                                     for B42 := A11[2] to B41 - 1 do
  165.                                                                                       for B43 := A11[1] to B42 - 1 do
  166.                                                                                         begin
  167.                                                                                           J := 1;
  168.                                                                                           for I := 1 to 6 do
  169.                                                                                             if (B41 <> A11[I]) and (B42 <> A11[I]) and (B43 <> A11[I]) then
  170.                                                                                               begin
  171.                                                                                                 A12[J] := A11[I];
  172.                                                                                                 J := J + 1
  173.                                                                                               end ;
  174.                                                                                           S[1] := KapacitaPrvku[B[1]] + KapacitaPrvku[B1] + KapacitaPrvku[B2] + KapacitaPrvku[B3];
  175.                                                                                           S[2] := KapacitaPrvku[B[2]] + KapacitaPrvku[B5] + KapacitaPrvku[B6] + KapacitaPrvku[B7];
  176.                                                                                           S[3] := KapacitaPrvku[B[3]] + KapacitaPrvku[B9] + KapacitaPrvku[B10] + KapacitaPrvku[B11];
  177.                                                                                           S[4] := KapacitaPrvku[B[4]] + KapacitaPrvku[B13] + KapacitaPrvku[B14] + KapacitaPrvku[B15];
  178.                                                                                           S[5] := KapacitaPrvku[B[5]] + KapacitaPrvku[B17] + KapacitaPrvku[B18] + KapacitaPrvku[B19];
  179.                                                                                           S[6] := KapacitaPrvku[B[6]] + KapacitaPrvku[B21] + KapacitaPrvku[B22] + KapacitaPrvku[B23];
  180.                                                                                           S[7] := KapacitaPrvku[B[7]] + KapacitaPrvku[B25] + KapacitaPrvku[B26] + KapacitaPrvku[B27];
  181.                                                                                           S[8] := KapacitaPrvku[B[8]] + KapacitaPrvku[B29] + KapacitaPrvku[B30] + KapacitaPrvku[B31];
  182.                                                                                           S[9] := KapacitaPrvku[B[9]] + KapacitaPrvku[B33] + KapacitaPrvku[B34] + KapacitaPrvku[B35];
  183.                                                                                           S[10] := KapacitaPrvku[B[10]] + KapacitaPrvku[B37] + KapacitaPrvku[B38] + KapacitaPrvku[B39];
  184.                                                                                           S[11] := KapacitaPrvku[B[11]] + KapacitaPrvku[B41] + KapacitaPrvku[B42] + KapacitaPrvku[B43];
  185.                                                                                           S[12] := KapacitaPrvku[B[12]] + KapacitaPrvku[A12[1]] + KapacitaPrvku[A12[2]] + KapacitaPrvku[A12[3]];
  186.                                                                                           MIN := S[1];
  187.                                                                                           MAX := S[1];
  188.                                                                                           for I := 2 to 12 do
  189.                                                                                             if MIN > S[I] then
  190.                                                                                               MIN := S[I]  
  191.                                                                                             else if MAX < S[I] then
  192.                                                                                               MAX := S[I] ;
  193.                                                                                           DELTA := MAX - MIN;
  194.                                                                                           if DELTA < MINDELTA then
  195.                                                                                             begin
  196.                                                                                               A[1, 1] := B[1];
  197.                                                                                               A[1, 2] := B1;
  198.                                                                                               A[1, 3] := B2;
  199.                                                                                               A[1, 4] := B3;
  200.                                                                                               A[2, 1] := B[2];
  201.                                                                                               A[2, 2] := B5;
  202.                                                                                               A[2, 3] := B6;
  203.                                                                                               A[2, 4] := B7;
  204.                                                                                               A[3, 1] := B[3];
  205.                                                                                               A[3, 2] := B9;
  206.                                                                                               A[3, 3] := B10;
  207.                                                                                               A[3, 4] := B11;
  208.                                                                                               A[4, 1] := B[4];
  209.                                                                                               A[4, 2] := B13;
  210.                                                                                               A[4, 3] := B14;
  211.                                                                                               A[4, 4] := B15;
  212.                                                                                               A[5, 1] := B[5];
  213.                                                                                               A[5, 2] := B17;
  214.                                                                                               A[5, 3] := B18;
  215.                                                                                               A[5, 4] := B19;
  216.                                                                                               A[6, 1] := B[6];
  217.                                                                                               A[6, 2] := B21;
  218.                                                                                               A[6, 3] := B22;
  219.                                                                                               A[6, 4] := B23;
  220.                                                                                               A[7, 1] := B[7];
  221.                                                                                               A[7, 2] := B25;
  222.                                                                                               A[7, 3] := B26;
  223.                                                                                               A[7, 4] := B27;
  224.                                                                                               A[8, 1] := B[8];
  225.                                                                                               A[8, 2] := B29;
  226.                                                                                               A[8, 3] := B30;
  227.                                                                                               A[8, 4] := B31;
  228.                                                                                               A[9, 1] := B[9];
  229.                                                                                               A[9, 2] := B33;
  230.                                                                                               A[9, 3] := B34;
  231.                                                                                               A[9, 4] := B35;
  232.                                                                                               A[10, 1] := B[10];
  233.                                                                                               A[10, 2] := B37;
  234.                                                                                               A[10, 3] := B38;
  235.                                                                                               A[10, 4] := B39;
  236.                                                                                               A[11, 1] := B[11];
  237.                                                                                               A[11, 2] := B41;
  238.                                                                                               A[11, 3] := B42;
  239.                                                                                               A[11, 4] := B43;
  240.                                                                                               A[12, 1] := B[12];
  241.                                                                                               A[12, 2] := A12[1];
  242.                                                                                               A[12, 3] := A12[2];
  243.                                                                                               A[12, 4] := A12[3];
  244.                                                                                               MINDELTA := DELTA;
  245.                                                                                               writeln();
  246.                                                                                               write('[');
  247.                                                                                               for I := 1 to 12 do
  248.                                                                                                 begin
  249.                                                                                                   write('[');
  250.                                                                                                   for J := 1 to 3 do
  251.                                                                                                     begin
  252.                                                                                                       write(A[I, J] : 2);
  253.                                                                                                       write(', ')
  254.                                                                                                     end;
  255.                                                                                                   write(A[I, 4]);
  256.                                                                                                   write(']');
  257.                                                                                                   if I < 12 then
  258.                                                                                                     write(', ') end ;
  259.                                                                                                   writeln(']')
  260.                                                                                                 end
  261.                                                                                             end
  262.  
  263.                                                                                         end
  264. end end end end end end end end end;
  265.                                                                                   writeln('Done.');
  266.                                                                                   readln;
  267.                                                                                 end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement