fork download
  1. #include <iostream> // sortc.cpp
  2. using namespace std; int main()
  3. { setlocale (LC_ALL, "RUS");
  4. srand(time(NULL)); int i,j;
  5. int n=12; int d[n], temp;
  6.  
  7. cout << " " << endl;
  8. for (i=0; i<n; i++) { d[i] = rand() % 9;}
  9.  
  10. for (i=0; i<6; i++) cout << d[i] << " ";
  11. for (i=n-6; i<n; i++) cout << d[i] << " ";
  12.  
  13. cout << " " << endl;
  14.  
  15. for (i=0; i<n-1; i++) for (j = i+1; j<n; j++)
  16. if (d[i]>d[j]) { temp=d[i]; d[i]=d[j]; d[j]=temp;}
  17.  
  18. cout << " " << endl;
  19.  
  20. i=0; while (i < 6)
  21. { cout << d[i] << " "; i++; }
  22. cout << " " << endl;
  23. i=n-6; while (i < n)
  24. { cout << d[i] << " "; i++; }
  25.  
  26. system("pause");
  27. }
Success #stdin #stdout #stderr 0.01s 5320KB
stdin
Standard input is empty
stdout
  
3 5 4 8 5 8 5 5 6 8 3 2   
  
2 3 3 4 5 5   
5 5 6 8 8 8 
stderr
sh: 1: pause: not found