MeehoweCK

Untitled

Nov 27th, 2020
615
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include "macierz.h"
  5.  
  6. using namespace std;
  7.  
  8. /*
  9. class Macierz
  10. {
  11.     int kolumny;
  12.     int wiersze;
  13.     float** wartosci;
  14. public:
  15.     Macierz(int, int, float);
  16.     Macierz(int, int);
  17. };
  18. */
  19.  
  20. Macierz::Macierz(int x, int y, float val) : kolumny(x), wiersze(y)
  21. {
  22.     wartosci = new float*[x];
  23.    
  24.     for(int i = 0; i < x; ++i)
  25.     {
  26.         wartosci[i] = new float(y);
  27.         for(int j = 0; j < y; ++j)
  28.         {
  29.             wartosci[i][j] = val;
  30.         }
  31.     }
  32. }
  33.  
  34. Macierz::Macierz(int x, int y) : kolumny(x), wiersze(y)
  35. {
  36.     srand(time(0));
  37.    
  38.     wartosci = new float*[x];
  39.    
  40.     for(int i = 0; i < x; ++i)
  41.     {
  42.         wartosci[i] = new float(y);
  43.         for(int j = 0; j < y; ++j)
  44.         {
  45.             wartosci[i][j] = 100.0 * rand() / RAND_MAX;
  46.         }
  47.     }
  48. }
RAW Paste Data