当前位置:网站首页>PAT B1076
PAT B1076
2022-06-25 19:55:00 【Madness makes freedom】
1076 Wifi password (15 branch )
Here's a picture circulating on Weibo :“ Dear students , Since you sometimes need to use wifi, I'm afraid to delay my parents' study , Will now wifi The password is set to answer the following math question :A-1;B-2;C-3;D-4; Please answer by yourself , Change every two days . Thank You for Your Cooperation !!~”—— In order to promote students' learning, teachers also work hard …… This question requires you to write a program to translate the answers to a series of questions into wifi Password . Let's simply assume that each multiple-choice question has 4 An option , Yes and only 1 Right answer .

Input format :
The first line of input gives a positive integer N(≤ 100), And then N That's ok , Each line follows Number - answer The format gives the of a problem 4 An option ,T Indicates the correct option ,F Indicates the wrong option . The options are separated by spaces .
Output format :
Output in one line wifi password .
sample input :
8
A-T B-F C-F D-F
C-T B-F A-F D-F
A-F D-F C-F B-T
B-T A-F C-F D-F
B-F D-T A-F C-F
A-T C-F B-F D-F
D-T B-F C-F A-F
C-T A-F B-F D-F
sample output :
13224143Wrote two codes , The first is to enter a set of data , Output a value , But I don't think this way is very good , Although it's right , But after all, the project will be done later , It is not possible to enter a value , Just output a value . therefore , I used one string To store the results .
The first code :
#include <iostream> #include <map> #include <cstdio> using namespace std; int main() { map<char,int> mp; for(int i=65,j=1;i<69;++i,++j) { mp.insert(make_pair(i,j)); } int n; cin >> n; getchar(); while(n--) { char c[4],answer[4]; for(int i=0;i<4;i++) { scanf("%c-%c",&c[i],&answer[i]); getchar(); if(answer[i]=='T') cout << mp[c[i]]; } } return 0; }
The second code :
#include <iostream> #include <map> #include <string> #include <cstdio> using namespace std; int main() { map<char,char> mp; for(int i=65,j=49;i<69;++i,++j) { mp.insert(make_pair(i,j)); } int n; string str; cin >> n; getchar(); while(n--) { char c[4],answer[4]; for(int i=0;i<4;i++) { scanf("%c-%c",&c[i],&answer[i]); getchar(); if(answer[i]=='T') str+=mp[c[i]]; } } cout << str << endl; return 0; }
边栏推荐
- QQ robot: self forbidden words management of group members [latest beta2 version]
- Redis cache preheating & avalanche & breakdown & penetration
- Elastic high-performance computing on the cloud supports the rapid development of the life science industry, reducing costs and increasing efficiency
- Database data type design (the most detailed in the whole network)
- PHP little knowledge record
- PHP FPM, workman, spoole, golang simple performance test
- 2、 Hikaricp source code analysis of connection acquisition process II
- 二、HikariCP获取连接流程源码分析二
- Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information
- Arduino read temperature
猜你喜欢

Bloom filter

Server journey from scratch - Yu Zhongxian integrated version (IP access server, LNMP compilation and installation, Lua environment and socket expansion)

Laravel validation rule followed Role of auth:: id()

mysql load data infile

Connecting PHP to MySQL instances in the lamp environment of alicloud's liunx system

On Oracle full stack virtual machine -- graalvm

Embark on a new journey and reach the world with wisdom

Ali vision AI training camp-day01
Android Development Notes - Quick Start (from sqllite to room licentiousness) 2

Arduino read temperature
随机推荐
Case: count the most characters and times
How to understand var = a = b = C = 9? How to pre parse?
Android Development Notes - Quick Start (from sqllite to room licentiousness) 2
Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information
Embark on a new journey and reach the world with wisdom
Network security detection and prevention test questions (I)
Pdf file download (the download name is the same as the file name)
Many varieties of EA can be used
5、 Initialization analysis II of hikaricp source code analysis
6、 Configuration resolution of hikariconfig
Arduino read temperature
Network security detection and prevention exercises (III)
What should I pay attention to in GoogleSEO content station optimization?
Elastic high-performance computing on the cloud supports the rapid development of the life science industry, reducing costs and increasing efficiency
Can GoogleSEO only do content without external chain? (e6zzseo)
The native JS mobile phone sends SMS cases. After clicking the button, the mobile phone number verification code is sent. The button needs to be disabled and re enabled after 60 seconds
Is it safe for tongdaxin to open an account?
New features of php7
DataX script task development record
What are Baidu collection skills? 2022 Baidu article collection skills