UCF Local Contest — September 5, 2015 Find the Twins(模拟)

Find the Twins filename: twins (Difficulty Level: Easy)
Dr. Orooji’s twins (Mack and Zack) play soccer. We will assume Mack wears jersey number 18 and Zack wears 17. So, Dr. O has to look for these two numbers when trying to find the twins.

The Problem:

Given a list of 10 numbers, determine if the twins are there.

The Input:

The first input line contains a positive integer, n, indicating the number of data sets to check. The sets are on the following n input lines, one set per line. Each set consists of exactly 10 single-space-separated distinct integers (each integer between 11 and 99 inclusive) giving the jersey numbers for the players.

The Output:
Print each input set. Then, on the next output line, print one of four messages (mack, zack, both, none), indicating how many of the twins are in the set. Leave a blank line after the output for each test case.

Sample Input:
4
11 99 88 17 19 20 12 13 33 44
11 12 13 14 15 16 66 88 19 20
20 18 55 66 77 88 17 33 44 11
12 23 34 45 56 67 78 89 91 18
Sample Output:
11 99 88 17 19 20 12 13 33 44 zack
11 12 13 14 15 16 66 88 19 20 none
20 18 55 66 77 88 17 33 44 11 both
12 23 34 45 56 67 78 89 91 18 mack

题目链接:https://nanti.jisuanke.com/t/43386

solution:比较简单的模拟

#include 
using namespace std;

int main()
{
	int n, temp;
	cin >> n;
	while (n--){
		bool m = false, z = false;
		for (int i = 0; i < 10; ++i){
			cin >> temp;
			if (temp == 18)m = true;
			else if (temp == 17)z = true;
			cout << temp;
			if (i != 9)putchar(' ');
			else putchar('\n');
		}
		if (z && m)cout << "both" << endl << endl;
		else if (z)cout << "zack" << endl << endl;
		else if (m)cout << "mack" << endl << endl;
		else cout << "none" << endl << endl;
	}
	return 0;
 } 

你可能感兴趣的:(模拟)