Untitled
unknown
plain_text
2 years ago
996 B
0
Indexable
Never
#include<iostream> #include<fstream> using namespace std; int main() { ifstream f( "matrice.txt" ); int v[21][31], n, m, i, j, min, max, lmax, lmin; cin >> n >> m; for ( i = 1; i <= m; i ++) for ( j = 1; j <= n; j ++) { f >> v[i][j]; if( i == 0 && j == 0) min = max = v[i][j]; else { if ( v[i][j] < min ) { min= v[i][j]; lmin = i; } if ( v[i][j] > max ) { max = v[i][j]; lmax = i; } } } for ( i = 1; i <= n; i ++) swap ( v[lmax][j] , v[lmin][j] ); for ( i = 1; i <= m; i ++) { for ( j = 1; j <= n; j ++) cout << v[i][j] << " "; cout << endl; } f.close(); return 0; }