daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Mar 20th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void utworz(int**& t,const unsigned n,const unsigned m)
  6. {
  7.     t = new int*[n];
  8.     for(unsigned int i=0;i<m;i++)
  9.         t[i] = new int[m];
  10.     for(unsigned int i=0;i<n;i++)
  11.         for(unsigned int j=0;j<m;j++)
  12.             t[i][j]=0;
  13. }
  14.  
  15. float utworz(const unsigned int n,const unsigned int m)
  16. {
  17.     float**tab=new float*[n];
  18.     for(unsigned int i=0;i<m;i++)
  19.         t[i] = new float[m];
  20.     for(unsigned int i=0;i<n;i++)
  21.         for(unsigned int j=0;j<m;j++)
  22.             t[i][j]=0;
  23.  
  24.     return tab;
  25. }
  26.  
  27. void wypisz(int*const* t,const unsigned n,const unsigned m)
  28. {
  29.     for(unsigned int i=0;i<n;i++)
  30.         {
  31.             for(unsigned int j=0;j<m;j++)
  32.                 cout<<t[i][j]<<"\t";
  33.             cout<<endl;
  34.         }
  35.  
  36. }
  37.  
  38. void usun(int*const* t,const unsigned n)
  39. {
  40.     for(unsigned int i=0;i<n;i++)
  41.          delete [] t[i];
  42.     delete [] t;
  43.     t=0;
  44. }
  45.  
  46.  
  47.  
  48. int main()
  49. {
  50.     int n,m;
  51.     cout<< "podaj n: ";
  52.     cin>>n;
  53.     cout<<"podaj m: ";
  54.     cin>>m;
  55.     int** a = 0;
  56.     utworz(a,n,m);
  57.     wypisz(a,n,m);
  58.  
  59.     float**b=utworz(n,m)
  60.  
  61.  
  62.     usun(a,n);
  63.     return 0;
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top