#include <stdio.h>
#include <iostream>
using namespace std;
void getvalue(int n[3],char txt[10]);
void sortprocess(int n[3]);
void display(int n[3],char txt[10]);
int n[3], one[3], two[3], three[3], txt[10];
int i,j,maxinarray=0,imax=0,tot=0,imin=9999,num=3,tmp;
void main() {
system(
"cls"
);
getvalue(one,
"One : "
);
getvalue(two,
"Two : "
);
getvalue(three,
"Three : "
);
sortprocess(one);
sortprocess(two);
sortprocess(three);
display(one,
"Sorting of one : "
);
display(two,
"Sorting of two : "
);
display(three,
"Sorting of three : "
);
cout <<
"Max of all = "
<< imax <<
"\n"
;
cout <<
"Min of all = "
<< imin <<
"\n"
;
cout <<
"Average of all = "
<< tot / 9;
getchar();
}
void getvalue(int n[3],char txt[10]) {
for
(i=0;i<num;i++) {
cout << txt << i+1 <<
" = "
;
cin >> n[i];
if
(imax < n[i]) { imax = n[i]; }
if
(imin > n[i]) { imin = n[i]; }
tot = tot + n[i];
}
}
void sortprocess(int n[3]) {
for
(i=0;i<num;i++) {
for
(j=num-1;j>i;j--) {
if
(n[j-1] > n[j]) {
tmp = n[j];
n[j] = n[j-1];
n[j-1] = tmp;
}
}
}
}
void display(int n[3],char txt[10]) {
maxinarray = 0;
cout << txt;
for
(i=0;i<num;i++) {
cout <<
" "
<< n[i] ;
if
(maxinarray < n[i]) { maxinarray = n[i]; }
}
cout <<
" Max : "
<< maxinarray <<
"\n"
;
}