Advertisement
czemu

Szlaczki zawijasy

Jan 3rd, 2022 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.05 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. void zad1()
  5. {
  6.     int i=1;
  7.     int tab[6][6];
  8.     for(int a=0; a<6; a++)
  9.     {
  10.         for(int g= 0; g<6; g++)
  11.         {
  12.             tab[a][g]=i;
  13.             i++;
  14.             cout <<tab[a][g]<<" ";
  15.         }
  16.         cout <<endl;
  17.     }
  18. }
  19. void zad2()
  20. {
  21.     int i=0;
  22.     int tab[6][6];
  23.     for(int a=0; a<6; a++)
  24.     {
  25.         for(int g= 0; g<6; g++)
  26.         {
  27.             tab[a][g]=i;
  28.              cout.width(2);
  29.             cout <<tab[a][g]<<" ";
  30.         }
  31.         cout <<endl;
  32.     }
  33. }
  34. void zad3()
  35. {
  36.     int tab[6][6];
  37.     for(int j=0; j<6;j++)
  38.     {
  39.         for(int g=0; g<6; g++)
  40.         {
  41.             if (j==g)
  42.             {
  43.                 tab[j][g]=1;
  44.             }
  45.             else
  46.                 {
  47.                     tab[j][g]=0;
  48.                     }
  49.                     cout <<tab[j][g]<<" ";
  50.         }
  51.         cout <<endl;
  52.     }
  53. }
  54. void zad4 ()
  55. {
  56.     int tab[6][6];
  57.     for (int f=0;f<6;f++)
  58.     {
  59.         for(int g=0;g<6;g++)
  60.         {
  61.             if(f>=g)
  62.                 tab[f][g]=1;
  63.             else
  64.             {
  65.                 tab[f][g]=0;
  66.             }
  67.             cout<<tab[f][g]<<" ";
  68.         }
  69.         cout << endl;
  70.     }
  71. }
  72. void zad5 ()
  73. {
  74.  
  75.     int x=6;
  76.     int tab[x][x];
  77.     for (int f=0;f<x;f++)
  78.     {
  79.         for(int g=0;g<x;g++)
  80.         {
  81.             if (g+f==x-1)
  82.                 tab[f][g]=1;
  83.             else
  84.                 tab[f][g]=0;
  85.             cout << tab[f][g]<<" ";
  86.         }
  87.         cout << endl;
  88.     }
  89.  
  90.  
  91.  
  92. }
  93. void zad6 ()
  94. {
  95.     int tab[6][6];
  96.     for (int f=0;f<6;f++)
  97.     {
  98.         for(int g=0;g<6;g++)
  99.         {
  100.             if(f+g>=6-1)
  101.                 tab[f][g]=1;
  102.             else
  103.                 tab[f][g]=0;
  104.             cout<<tab[f][g]<<" ";
  105.         }
  106.         cout << endl;
  107.     }
  108. }
  109. void zad7()
  110. {
  111.     int i=0;
  112.     int tab[6][6];
  113.     {
  114.         for(int g=0;g<6;g++)
  115.         {
  116.             for(int j=0;j<6;j++)
  117.             {
  118.                 tab[j][g]=i;
  119.             i++;
  120.             }
  121.         }
  122.         for(int g=0;g<6;g++)
  123.         {
  124.             for(int j=0;j<6;j++)
  125.             {
  126.                 cout <<tab[j][g]<<" ";
  127.             }
  128.             cout <<endl;
  129.     }
  130. }
  131. }
  132. void zad8 ()
  133. {
  134.        int i=1;
  135.     int x=6;
  136.     int tab[x][x];
  137.  
  138.     for(int g=0;g<x;g++)
  139.     {
  140.         if (g%2==0)
  141.         {
  142.             for(int f=0;f<x;f++)
  143.             {
  144.                 tab [g][f]=i;
  145.                 i++;
  146.             }
  147.         }
  148.         else
  149.         {
  150.             for(int f=x-1;f>=0;f--)
  151.             {
  152.                 tab [g][f]=i;
  153.                 i++;
  154.             }
  155.         }
  156.     }
  157.  
  158.     for(int g=0;g<x;g++)
  159.     {
  160.         for(int f=0;f<x;f++)
  161.         {
  162.             cout << tab[g][f] << " ";
  163.         }
  164.     cout << endl;
  165.     }
  166.  
  167. }
  168. int main()
  169. {
  170.     zad1();
  171.     cout <<endl;
  172.     zad2();
  173.     cout <<endl;
  174.     zad3();
  175.     cout <<endl;
  176.     zad4();
  177.     cout <<endl;
  178.     zad5();
  179.     cout <<endl;
  180.     zad6();
  181.     cout <<endl;
  182.     zad7();
  183.     cout <<endl;
  184.     zad8();
  185.     return 0;
  186. }
  187.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement