PAT B1076 Wifi password (15 points)

Topic links : https://pintia.cn/problem-sets/994805260223102976/problems/994805262622244864

Title Description
Here is circulating on Weibo photo: "Dear students, given that we sometimes need to use wifi, afraid to delay the pro learning, now wifi password is set to answer the following math problem: A-1; B-2; C-3; D-4;. ask someone to answer their own, a change every two days - thank you !! "- teachers to promote student learning is the fight ...... this question requires you to write the program title translated into a series of answers wifi password is given in accordance with the correspondence between the papers. Here simply assume that each multiple-choice questions have four options and only one correct answer.
Here Insert Picture Description

Enter the
given input first line a positive integer N (≤ 100), followed by N lines, each in accordance with the number - gives four options for a question answer format, T is the correct option, F indicates an error options. Separated by spaces option.

Output
Output wifi passwords in a row.

样例输入
8
AT BF CF DF
King BF DF AF
AF DF CF BT
BT AF CF DF
BF DT AF CF
AT CF BF DF
DT BF CF AF
Ct AF BF DF

Sample output
13,224,143

Code

#include <cstdio>
#include <map>

using namespace std;

int main() {
	int n, count[1010], num = 0;
	char a, b;
	map<char, int> mp;
	mp['A'] = 1;
	mp['B'] = 2;
	mp['C'] = 3;
	mp['D'] = 4;
	scanf("%d", &n);
	for(int j= 0; j < n; j++) {
		for(int i = 0; i < 4; i++) {
			getchar();
			scanf("%c-%c", &a, &b);
			
			if(b == 'T') {
				count[num++] = mp[a];
				//break;				//不能加break;
			}
		}
	}
	for(int i = 0; i < num; i++)
		printf("%d", count[i]);
	printf("\n");
	return 0;
}
Published 288 original articles · won praise 12 · views 20000 +

Guess you like

Origin blog.csdn.net/Rhao999/article/details/104724006