View Code of Problem 612

#include <iostream>
using namespace std;

int main() {
	int a[6];
	while(cin >>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]){
		int max1=0,min1=5;
		for(int i=0;i<6;i++){
			if(a[max1]<a[i]){
				max1=i;
			}
		}
		for(int i=5;i>=0;i--){
			if(a[min1]>a[i]){
				min1=i;
			}
		}
		int sum=0;
		for(int i=0;i<6;i++){
			if((i!=max1)&&(i!=min1)){
				sum+=a[i];
			}
		}
		cout << (float)sum/4<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 612