//03、编写一个程序,要求从键盘输入四科成绩,求出该生最高成绩与最低成绩。
#include<iostream>
using namespace std;
int main(void)
{
int nGread[6] = {0};
cout << "请输入四科成绩" << endl;
for (int i = 0; i < 4; ++i)
{
cin >> nGread[i];
}
for (int i = 1; i < 4; ++i)
{
// 求最大值
if (nGread[i ] - nGread[0] > nGread[4])
{
nGread[4] = nGread[i] - nGread[0];
}
// 求最小值
if (nGread[i] - nGread[0] < nGread[5])
{
nGread[5] = nGread[i] - nGread[0];
}
}
nGread[4] = nGread[4] + nGread[0]; // nGread[4] 为最大值
nGread[5] = nGread[0] + nGread[5]; // nGread[5] 为最小值
for (int i = 0; i < 6; ++i)
{
cout << nGread[i] << " ";
}
return 0;
}