Advertisement
Alberts00

insertionsort

Oct 2nd, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.    
  9.     int mas[5];
  10.     for (int i=0; i<5; i++) {cin >> mas[i];}
  11.     int N;
  12.  for(int x=1;x<N; x++) {
  13.   int a=mas[x];
  14.   int y=x;
  15.   while((a<mas[y-1])&&(y>0)) {
  16.     mas[y]=mas[y-1];
  17.     y--;
  18.   }
  19.   mas[y]=a;
  20.  
  21. }
  22.      cout << "sakartots"<<endl;
  23.     for (int i=0; i<5; i++) {cout << mas[i]<<endl;}
  24.  
  25.     system("PAUSE");
  26.     return EXIT_SUCCESS;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement