Advertisement
Guest User

Untitled

a guest
May 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void wyswietl(int wysokosc, int szerokosc, int **tab)
  5. {
  6.     if (tab == NULL)
  7.         return;
  8.  
  9.     for (int i = 0; i < wysokosc; i++)
  10.     {
  11.         for (int j = 0; j < szerokosc; j++)
  12.         {
  13.             cout << tab[i][j] << " ";
  14.         }
  15.         cout << endl;
  16.     }
  17. }
  18.  
  19. int main()
  20. {
  21.     int wysokosc = 4;
  22.     int szerokosc = 7;
  23.  
  24.     // Deklaracja tablicy
  25.     int **tablica = new int *[wysokosc];
  26.     for (int i = 0; i < wysokosc; i++)
  27.     {
  28.         tablica[i] = new int [szerokosc];
  29.     }
  30.    
  31.     // Inicjalizacja zmiennych danymi
  32.     for (int i = 0; i < 4; i++)
  33.     {
  34.         for (int j = 0; j < 7; j++)
  35.         {
  36.             tablica[i][j] = i + j * j;
  37.         }
  38.     }
  39.  
  40.     // Uzycie funkcji
  41.     wyswietl(wysokosc, szerokosc, tablica);
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement