Uhmm, Hi!~ Can someone help me to array the result average into highest to lowest.. Thank you
Uhmm, if you cant get me, here's my example
If i had already got the average and the result is
78
90
70
80
(my code is user-define. so please dont use pre-define)
then i need to arrange it into highest to lowest by the use of array
so, what code should i use?
P.S.: You can separate it to my output if you want~
Thank You~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
using namespace std;
int main()
{
int quiz1[5], quiz2[5], i;
int sum=0;
float avg=0.0;
for (i=1; i<5; i++)
{
cout<<"\nInput Quiz 1 of Student# "<<i<<": ";
cin>>quiz1[i];
cout<<"Input Quiz 2 of Student# "<<i<<": ";
cin>>quiz2[i] ;
}
cout<<"\n Student# Quiz 1 Quiz 2 Average\n";
for (i=1; i<5; i++)
{
sum=quiz1[i]+quiz2[i];
avg=sum/2;
cout<<" #"<<i<<" "<< quiz1[i] << " " << quiz2[i] << " "<<avg<< "\n";
}
return 0;
}
|
Sample OUTPUT
Input Quiz 1 of Student# 1: 87
Input Quiz 2 of Student# 1: 95
Input Quiz 1 of Student# 2: 97
Input Quiz 2 of Student# 2: 85
Input Quiz 1 of Student# 3: 89
Input Quiz 2 of Student# 3: 90
Input Quiz 1 of Student# 4: 78
Input Quiz 2 of Student# 4: 56
Student# Quiz 1 Quiz 2 Average
#1 87 95 91
#2 97 85 91
#3 89 90 89
#4 78 56 67