九度 题目1002:Grading

模拟题。代码:

#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
	float p, t, g1, g2, g3, gj;

	while (cin >> p >> t >> g1 >> g2 >> g3 >> gj)
	{
		if (abs(g1-g2) <= t)
		{
			printf("%.1f\n", (g1+g2)/2.0);
		} else if (abs(g1-g3)<=t && abs(g2-g3)<=t)
		{
			printf("%.1f\n", max(max(g1,g2), g3));
		} else if (abs(g1-g3)<=t || abs(g2-g3)<=t)
		{
			if (abs(g1-g3) < abs(g2-g3))
			{
				printf("%.1f\n", (g1+g3)/2.0);
			} else
			{
				printf("%.1f\n", (g2+g3)/2.0);
			}
		} else
		{
			printf("%.1f\n", gj);
		}
	}

	return 0;
}


你可能感兴趣的:(C++,模拟,九度,Jobdu)