Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

划水老头

Posted by uncleD at 2019-08-22 15:06:02 on Problem 3781
// poj3781.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
	int p;
	int set;
	int max[3];
	int value[10];

	cin >> p;

	while (p--)
	{
		cin >> set;
		for (int i = 0; i < 10; i++)
			cin >> value[i];

		for (int i = 0; i < 3; i++)
			max[i] = -1;

		for (int i = 0; i < 10; i++)
			if (value[i] > max[0])
			{
				max[2] = max[1];
				max[1] = max[0];
				max[0] = value[i];
			}
			else if (value[i] > max[1])
			{
				max[2] = max[1];
				max[1] = value[i];
			}
			else if (value[i] > max[2])
			{
				max[2] = value[i];
			}

		cout << set << ' ' << max[2] << endl;
	}


	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator