Advertisement
andragabr

Untitled

Jan 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<time.h>
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. int i,j, min, tmp=0, n=4;
  10. int a[n];
  11.  
  12.  
  13.  
  14. for (i=0; i<n; i++)
  15. {
  16. a[i]=random( ) % 100 ;
  17. }
  18.  
  19. for (i = 0; i < n - 1; ++i) {
  20. min = i;
  21. for (j = i + 1; j < n; ++j)
  22. if (a[j] < a[min])
  23. min = j;
  24. tmp = a[i];
  25. a[i] = a[min];
  26. a[min] = tmp;
  27. }
  28.  
  29. cout<<endl;
  30.  
  31. cout << min<<endl;
  32. cout<<endl;
  33.  
  34. for (i=0; i<4 ; i++)
  35. {
  36. cout<<a[i] << endl;
  37.  
  38. }
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement