03, write a program that requires input from the keyboard results in four subjects, the student obtained the highest score and the lowest score.

// 03, write a program that requires input from the keyboard results in four subjects, the student obtained the highest score and the lowest score.
#include <the iostream>
the using namespace STD;

main int (void)
{
int nGread [. 6] = {0};
COUT << "Please enter the four subjects scores" << endl;
for (int I = 0; I <. 4; I ++)
{
CIN >> nGread [I];
}
for (int I =. 1; I <. 4; I ++)
{
// find the maximum value
IF (nGread [I] - nGread [0]> nGread [. 4])
{
nGread [. 4] = nGread [I] - nGread [0];
}

// minimization
IF (nGread [I] - nGread [0] <nGread [. 5])
{
nGread [. 5] = nGread [I] - nGread [0];
}
}
nGread [4] = nGread [4 ] + nGread [0]; // nGread [4] is the maximum
nGread [5] = nGread [0 ] + nGread [5]; // nGread [5] to a minimum value

for (int i = 0; i < 6; ++i)
{
cout << nGread[i] << "\t";
}

return 0;
}

 

Guess you like

Origin www.cnblogs.com/tito/p/12373300.html