yoyoboyss

Untitled

Jun 24th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. int n, v[1000], temp;
  8.  
  9. cout << "n= "; cin >> n;
  10. for(int i = 0; i < n; i++){
  11. cout << "v[" << i << "]= ";
  12. cin >> v[i];
  13. }
  14.  
  15. for(int i = 0; i < n; i++){
  16. for(int j = i; j < n; j++){
  17. if(v[j] < v[i]){
  18. temp = v[j];
  19. v[j] = v[i];
  20. v[i] = temp;
  21. }
  22. }
  23. }
  24.  
  25. for(int i = 0; i < n; i++){
  26. cout << v[i] << ' ';
  27. }
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment