Advertisement
Dvortsov_D1

dodelat table 3*9 funk tablegav

Nov 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void uber(int **a,int n){
  4.     int ch=0;
  5.     for(int i=0;i<n;i++){
  6.         for(int j=0;j<n;j++){
  7.             ch+=1;
  8.             a[i][j]=ch;
  9.         }
  10.     }
  11. }
  12.  
  13. void print(int **a,int n){
  14.     for(int i=0;i<n;i++){
  15.         for(int j=0;j<n;j++){
  16.             cout<<a[i][j]<<"\t";
  17.         }
  18.         cout<<endl<<endl;
  19.     }
  20. }
  21.  
  22. void transpose(int ** a, int n){
  23.     int c=0;
  24.  
  25.     for(int i=0;i<n;i++){
  26.         for(int j=0;j<n;j++){
  27.             if (j < i){
  28.                 c=a[j][i];
  29.                 a[j][i] = a[i][j];
  30.                 a[i][j] = c;
  31.             }
  32.         }
  33.     }
  34. }
  35.  
  36. void table (int n ){
  37.     for ( int i=1;i<n;i++){
  38.         cout << endl;
  39.         for (int j=1;j<n;j++){
  40.             cout<<i<<" x "<<j<<" = "<<j*i<<endl;
  41.  
  42.  
  43.         }
  44.     }
  45. }
  46.  
  47. void tablegav (int n, int g){
  48.     for (int i=1;i<n;i++){
  49.         for (int j=1;j<g;j++){
  50.            
  51.            
  52.         }
  53.     }
  54.   }  
  55. int main()
  56. {
  57.     int b=5;
  58.     int **ptr = new int *[b];
  59.     for ( int i=0; i<b; i++){
  60.        ptr[i] = new int [b];
  61.        for(int j=0;j<b;j++){
  62.            ptr[i][j]=0;
  63.            }
  64.     }
  65.     uber (ptr,b);
  66.     print (ptr,b);
  67.     cout << endl;
  68.     transpose(ptr, b);
  69.     print (ptr,b);
  70.     table(b);
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement