Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Formiranje niza tako sto je b[j] jednak razlici maximalnog i minimalnog clana kolone */
- #include <iostream>
- using namespace std;
- main()
- {
- int a[50][50], b[50], m, n, i, j, max, min;
- cin >> m >> n;
- for (i=0; i<m; i++)
- for (j=0; j<n; j++)
- cin >> a[i][j];
- for (j=0; j<n; j++)
- {
- max = a[0][j];
- min = a[0][j];
- for (i=1; i<m; i++)
- {
- if (a[i][j] > max)
- max = a[i][j];
- if (a[i][j] < min)
- min = a[i][j];
- }
- b[j] = max - min;
- }
- cout << endl;
- /* Stampanje matrice */
- /* for (i=0; i<m; i++)
- {
- for (j=0; j<n; j++)
- cout << a[i][j] << " ";
- cout << endl;
- }
- */
- for (j=0; j<n; j++)
- cout << b[j] << " ";
- system ("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment