View Code of Problem 75

#include<iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cmath>
using namespace std;


int main() {
	int  s1[100];
	int min, max, n;
	min = 0;
	max = 0;
	n = 10;
	for (int i = 0; i < 10; i++) {
		scanf("%d", &s1[i]);
	}
	for (int i = 0; i < 10; i++) {
		if (s1[i] > s1[max]) {
			max = i;
		}
	}
	while (n > 0) {
		for (int i = 0; i < 10; i++) {
			if (s1[i] < s1[min]) {
				min = i;
			}
		}
	if(n==1)
		printf("%d", s1[min]);
	else
		printf("%d ", s1[min]);
	s1[min] = s1[max];
	n--;
	}
	return 0;
}	

Double click to view unformatted code.


Back to problem 75