Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstdlib>
  4. #include <ctime>
  5. using namespace std;
  6.  
  7. struct macierz {
  8.  
  9. vector<vector<int>>v_2d;
  10.  
  11. };
  12.  
  13. int main() {
  14. srand(time(NULL));
  15. int x = rand() % 100 + 1;
  16. int y = rand() % 100 + 1;
  17.  
  18. macierz a;
  19. int liczba_wierszy = x;
  20. int liczba_kolumn = y;
  21. cout << "Wylosowana liczba wierszy to: " << liczba_wierszy << endl;
  22. cout << "Wylosowana liczba kolumn to: " << liczba_kolumn << endl;
  23. for (int i = 0; i < liczba_wierszy; i++) {
  24. vector<int>wiersze;
  25. for (int j = 0; j < liczba_kolumn; j++) {
  26. wiersze.push_back(10*i+j);
  27. }
  28. a.v_2d.push_back(wiersze);
  29. }
  30.  
  31. int b, bb;
  32. cout << "Jaki wiersz ?";
  33. cin >> b;
  34. cout << "Jaka kolumna ?";
  35. cin >> bb;
  36.  
  37. cout << "Wynik "<< a.v_2d[b][bb] << endl;
  38.  
  39.  
  40.  
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement