SHARE
TWEET

Lab5B

a guest Nov 19th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include <iomanip>
  3. #include <ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int m, n, i, j;
  8.     cout << "Enter number of strings:";
  9.     cin >> n;
  10.     cout << "Enter number of colums:";
  11.     cin >> m;
  12.     cout << "We have the" << " a[" << n << "][" << m << "]." << endl;
  13.     int** a = new int* [n];
  14.     for (i = 0; i < n; i++)
  15.         a[i] = new int[m];
  16.     for (i = 0; i < n; i++)
  17.         for (j = 0; j < m; j++)
  18.         /*{
  19.             cin >> a[i][j];
  20.         }*/
  21.     a[i][j] = rand() % 80 + 1;
  22.  
  23.     cout << " The [" << n << "][" << m << "]" << " Array :" << endl;
  24.  
  25.     for (i = 0; i < n; i++)
  26.     {
  27.         for (j = 0; j < m; j++)
  28.         {
  29.             cout << a[i][j];
  30.             cout << '\t';
  31.         }
  32.         cout << endl << endl;
  33.     }
  34.     ///////////////////
  35.     int jmax = 0, k = 0, imax = 0;
  36.  
  37.     for (i = 0; i < n; i++)
  38.     {
  39.         for (j = 0; j < m; j++)
  40.         {
  41.             if (a[imax][jmax] < a[i][j])
  42.             {
  43.                 jmax = j;
  44.                 imax = i;
  45.             }
  46.  
  47.         }
  48.  
  49.     }
  50.     cout << "It is the max element in colum(s) number :";
  51.     for (i = 0; i < n; i++)
  52.     {
  53.         for (j = 0; j < m; j++)
  54.         {
  55.             if (a[imax][jmax] == a[i][j])
  56.                 cout << j + 1 << "," << " ";
  57.  
  58.         }
  59.  
  60.     }
  61.  
  62.     cout << "/////////////////////////////////////" << endl;
  63.  
  64.     for (i = 0; i < n; i++)
  65.     {
  66.         for (j = jmax; j < m-1; j++)
  67.         {
  68.             a[i][j] = a[i][j + 1];
  69.  
  70.         }
  71.  
  72.     }
  73.     cout << "New Array [" << i << "][" << j - 1 << "]:"<<endl;
  74.     for (i = 0; i < n; i++)
  75.     {
  76.         for (j = 0; j < m - 1; j++)
  77.         {
  78.             cout << a[i][j] << '\t';
  79.         }
  80.         cout << endl;
  81.     }
  82.  
  83.  
  84.  
  85.     //////////////////////
  86.     for (i = 0; i < n; i++)
  87.             delete [] a[i];
  88.        
  89.         delete [] a;
  90.  
  91.     return 0;
  92. }
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