Advertisement
icatalin

sortrare materice metoda 1

May 16th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a[100][100],n,i,j,x,m,aux;
  8.     cout<<"n= ";cin>>n;
  9.     cout<<"m= ";cin>>m;
  10.     for (i=1;i<=n;i++)
  11.     for (j=1;j<=m;j++)
  12.     {
  13.         cout<<"a["<<i<<"]["<<j<<"]= ";
  14.     cin>>a[i][j];
  15.     }
  16. for (x=1;x<=n;x++)
  17. {  for (i=1;i<=m-1;i++)
  18.         for (j=i+1;j<=m;j++)
  19.         if (a[x][i]>a[x][j])
  20.     {
  21.         aux=a[x][i];
  22.         a[x][i]=a[x][j];
  23.         a[x][j]=aux;
  24.     }
  25. }
  26.  
  27.  
  28.     for (i=1;i<=n;i++)
  29.     {for (j=1;j<=m;j++)
  30.     cout<<a[i][j]<<" ";
  31.     cout<<'\n';
  32.     }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement