Advertisement
Gireada

Tema nr.17

Apr 22nd, 2013
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. //Tema nr.17
  2.  
  3. #include<iostream.h>
  4. #include<conio.h>
  5.  
  6. int main()
  7. {
  8.     int v[100],i,k,n,s;
  9.     cout<<"n=";cin>>n;
  10.     for(i=0;i<n;i++)
  11.     {
  12.         cout<<"V["<<i<<"]=";cin>>v[i];
  13.     }
  14.  
  15.     for(i=0;i<n-1;i++)
  16.         for(k=i+1;k<n;k++)
  17.         {c++;
  18.             if(!v[i]>v[k])
  19.             {
  20.                 s=v[i];
  21.                 v[i]=v[k];
  22.                 v[i]=s;
  23.             }
  24.         }
  25.     for(i=0;i<n;i++)
  26.         cout<<v[i]<<" ";
  27.        
  28.     getch();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement