50 de puncte!!!!
urgent!!!
dau coroana!!!!
Răspunsuri la întrebare
Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
ofstream f("rez.txt");
int main(){
int n,m,a[101][101];
cin>>n>>m;
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
cin>>a[i][j];
}
}
for(int j=1;j<m;++j){
for(int i=j+1;i<=m;++i){
if(a[n][j]>a[n][i])swap(a[n][j],a[n][i]);
}
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
f<<a[i][j]<<" ";
}
cout<<endl;
}
for(int i=1;i<n;++i){
for(int j=i+1;j<=n;++j){
if(a[i][m]<a[j][m])swap(a[i][m],a[j][m]);
}
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
cout<<a[i][j]<<" ";
}
cout<<endl;
}
f.close();
return 0;
}
Explicație: