Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <iomanip>
- #include <ctime>
- using namespace std;
- int main()
- {
- int m, n, i, j;
- cout << "Enter number of strings:";
- cin >> n;
- cout << "Enter number of colums:";
- cin >> m;
- cout << "We have the" << " a[" << n << "][" << m << "]." << endl;
- int** a = new int* [n];
- for (i = 0; i < n; i++)
- a[i] = new int[m];
- for (i = 0; i < n; i++)
- for (j = 0; j < m; j++)
- /*{
- cin >> a[i][j];
- }*/
- a[i][j] = rand() % 80 + 1;
- cout << " The [" << n << "][" << m << "]" << " Array :" << endl;
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < m; j++)
- {
- cout << a[i][j];
- cout << '\t';
- }
- cout << endl << endl;
- }
- ///////////////////
- int jmax = 0, k = 0, imax = 0;
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < m; j++)
- {
- if (a[imax][jmax] < a[i][j])
- {
- jmax = j;
- imax = i;
- }
- }
- }
- cout << "It is the max element in colum(s) number :";
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < m; j++)
- {
- if (a[imax][jmax] == a[i][j])
- cout << j + 1 << "," << " ";
- }
- }
- cout << "/////////////////////////////////////" << endl;
- for (i = 0; i < n; i++)
- {
- for (j = jmax; j < m-1; j++)
- {
- a[i][j] = a[i][j + 1];
- }
- }
- cout << "New Array [" << i << "][" << j - 1 << "]:"<<endl;
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < m - 1; j++)
- {
- cout << a[i][j] << '\t';
- }
- cout << endl;
- }
- //////////////////////
- for (i = 0; i < n; i++)
- delete [] a[i];
- delete [] a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement