当前位置:网站首页>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 :
13224143
Wrote 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; }
边栏推荐
- Vscode debugging PHP configuration Xdebug
- 2、 Hikaricp source code analysis of connection acquisition process II
- Cutting feet to fit shoes - talking about the ramp reconstruction on the track
- 在打新債開戶證券安全嗎?低傭金靠譜嗎
- ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS
- New features of php7
- Vulnhub range the planes:earth
- 六、HikariConfig的配置解析
- Pdf file download (the download name is the same as the file name)
- Error record: preg_ match(): Compilation failed: range out of order in character class at offset 13
猜你喜欢
Mail monitoring cloud script execution progress
Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information
Uncover ges super large scale graph computing engine hyg: Graph Segmentation
What should I pay attention to in GoogleSEO content station optimization?
QQ robot epidemic situation query / epidemic situation concern [latest beta2 version]
How to understand var = a = b = C = 9? How to pre parse?
Jsonp processing non homologous
Wechat applet swiper simple local picture display appears large blank
Principles of MySQL clustered index and non clustered index
Applet canvas generate sharing Poster
随机推荐
Network security detection and prevention test questions (II)
QQ robot: self forbidden words management of group members [latest beta2 version]
Uniapp waterfall flow, applet waterfall flow, very simple, suitable for the whole platform
Network security detection and prevention test questions (4)
Please do not call Page constructor in files
Can the stock account opened through qiniu school be used? Is the fund safe?
Simple native JS tab bar switching
Applet request interface encapsulation
QQ robot flash forwarding / recall message forwarding [latest beta2 version]
Can GoogleSEO only do content without external chain? (e6zzseo)
Est - il sûr d'ouvrir un compte avec de nouvelles dettes? Une faible Commission est - elle crédible?
Force wechat page font size to be 100%
Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information
On Oracle full stack virtual machine -- graalvm
QQ robot official plug-in loading configuration method [beta2 version]
JS get the parameters in the URL link
Tcp/ip test questions (V)
Bindgetuserinfo will not pop up
Jsonp processing non homologous
Arduino : No such file or directory