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