Advertisement
Guest User

Tablice wielowymiarowe

a guest
Dec 12th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int tab[100][100];
  7.  
  8. void losuj(int wiersze, int kolumny)
  9. {
  10.     for (int i = 0; i < wiersze; i++)
  11.     {
  12.         for (int j = 0; j < kolumny; j++)
  13.             tab[i][j] = rand() % 20;
  14.     }
  15. }
  16.  
  17. void wypisz(int wiersze, int kolumny)
  18. {
  19.     for (int i = 0; i < wiersze; i++)
  20.     {
  21.         for (int j = 0; j < kolumny; j++)
  22.         {
  23.             cout << setw(3) << tab[i][j];
  24.         }
  25.         cout << endl;
  26.     }
  27. }
  28.  
  29.  
  30. int _tmain(int argc, _TCHAR* argv[])
  31. {
  32.     int w, k;
  33.     cout << "Ile wierszy i kolumn? ";
  34.     cin >> w >> k;
  35.     losuj(w, k);
  36.     wypisz(w, k);
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement