Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- using namespace std;
- int main() {
- int i,j, min, tmp=0, n=4;
- int a[n];
- for (i=0; i<n; i++)
- {
- a[i]=random( ) % 100 ;
- }
- for (i = 0; i < n - 1; ++i) {
- min = i;
- for (j = i + 1; j < n; ++j)
- if (a[j] < a[min])
- min = j;
- tmp = a[i];
- a[i] = a[min];
- a[min] = tmp;
- }
- cout<<endl;
- cout << min<<endl;
- cout<<endl;
- for (i=0; i<4 ; i++)
- {
- cout<<a[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement