Advertisement
Voldemord

zad5/6 main

Dec 1st, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include "headers.hpp"
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7. double ** renderArr(int m, int n){
  8.     double **arr = new double *[m];
  9.  
  10.     for(int i=0;i<m;i++)
  11.         arr[i] = new double [n];
  12.  
  13.     for(int i=0;i<m;i++)
  14.         for(int j=0;j<n;j++)
  15.             arr[i][j] = rand()%10;
  16.  
  17.     return arr;
  18. }
  19.  
  20. void showArr(int m, int n, double ** arr){
  21.     for(int i=0;i<m;i++){
  22.         for(int j=0;j<n;j++)
  23.             cout<<arr[i][j]<<" ";
  24.         cout<<endl;
  25.     }
  26. }
  27.  
  28. int main()
  29. {
  30.     srand (time(NULL));
  31.  
  32.     cout<<endl << "Zwykla tablica" <<endl;
  33.     double **tablica = renderArr( 5, 6 ); //tworzenie tablicy dynamiczna
  34.     showArr(5, 6, tablica);
  35.  
  36.     cout<<endl << "---Macierze----" <<endl;
  37.  
  38.     MyMother * a;
  39.  
  40.     cout<<endl << "Z pustym konstruktorem" <<endl;
  41.     a = new MyMother();
  42.  
  43.  
  44.     a->showMyMother();
  45.  
  46.     cout<<endl << "Z randomowym generowaniem od 0 do 1" <<endl;
  47.  
  48.     a = new MyMother(3,3, tablica); //przekazanie tablicy na macierz
  49.     a->genRandMother();
  50.     a->showMyMother();
  51.  
  52.  
  53.     cout<<endl << "Z przepisaniem z tablicy" <<endl;
  54.     a = new MyMother(5,5,tablica);
  55.     a->showMyMother();
  56.  
  57.     cout<<endl << "Obciecie wielkosci macierzy" <<endl;
  58.     a->resizeMother(2,2);
  59.     a->showMyMother();
  60.     cout<<endl << "Zwiekszenie wielkosci macierzy" <<endl;
  61.     a->resizeMother(4,4);
  62.     a->showMyMother();
  63.     cout<<endl << "Wiele wiecej ale nie chce mi sie pisac" <<endl;
  64.     cout << "Done!" << endl;
  65.     //delete a;
  66.  
  67.     MyMother * b;
  68.     MyMother * c;
  69.     b = new MyMother();
  70.     c = new MyMother();
  71.     b->genRandMother();
  72.     c = b;
  73.     b->showMyMother();
  74.     cout << endl;
  75.  
  76.     c->mother[0][0] = 1;
  77.     c->showMyMother();
  78.     //a = b + c;
  79.     cout << (b == c) << endl;
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement