Advertisement
SergeyPGUTI

8.2.2

Feb 18th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string.h>
  4. #include<cstdlib>
  5. #include<ctime>
  6.  
  7. using namespace std;
  8.  
  9.  
  10.  
  11. int main()
  12. {
  13.     int n,m;
  14.     srand((unsigned)time(0));
  15.     cin>>n;
  16.     cin>>m;
  17.     int ** p= new int*[n];
  18.     int ** newP=new int*[n];
  19.  
  20.     for (int i=0;i<n;i++)
  21.     {
  22.         p[i]=new int[m];
  23.     }
  24.  
  25.     for (int i=0;i<n;i++)
  26.         for (int j=0;j<m;j++)
  27.             p[i][j]=rand()%1000;
  28.  
  29.     //заполним newP
  30.  
  31.     for (int i=0;i<n;i++)
  32.     {
  33.         newP[i]=new int[m];
  34.     }
  35.  
  36.     for (int i=0;i<n;i++)
  37.         for (int j=0;j<m;j++)
  38.             newP[i][j]=p[j][i];
  39.     //вывод p
  40.     for (int i=0;i<n;i++)
  41.     {
  42.  
  43.         for (int j=0;j<m;j++)
  44.             {
  45.                 cout.width(3);
  46.                 cout<<p[i][j]<<" ";
  47.             }
  48.             cout<<endl;
  49.     }
  50.  
  51.     cout<<endl;cout<<endl;cout<<endl;
  52.    
  53.     //вывод newP
  54.  
  55.     for (int i=0;i<n;i++)
  56.     {
  57.  
  58.         for (int j=0;j<m;j++)
  59.             {
  60.                 cout.width(3);
  61.                 cout<<newP[i][j]<<" ";
  62.             }
  63.             cout<<endl;
  64.     }
  65.  
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement