Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int a[100][100],n,m,i,j,k,aux;
- cout<<"n=";cin>>n;
- cout<<"m=";cin>>m;
- for (i=0;i<n;i++)
- for (j=0;j<m;j++)
- cin>>a[i][j];
- k=0;
- int temp[n*m];
- for (i=0;i<n;i++)
- for (j=0;j<m;j++) {
- temp[k]=a[i][j];
- k++;
- }
- for (i=0;i<k-1;i++)
- for (j=i+1;j<k;j++)
- if (temp[i]>temp[j])
- {
- aux=temp[i];
- temp[i]=temp[j];
- temp[j]=aux;
- }
- k=0;
- for (i=0;i<n;i++)
- for (j=0;j<m;j++) {
- a[i][j]=temp[k];
- k++;
- }
- for(i=0;i<n;i++) {
- for (j=0;j<m;j++)
- cout<<a[i][j]<<' ';
- cout<<endl;}//*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement