当前位置:网站首页>L1-030 one gang one (15 points)
L1-030 one gang one (15 points)
2022-07-04 07:29:00 【Inter personal liabilities^】
L1-030 One gang, one (15 branch )
“ A group of students ” It is a common way of learning organization in primary and secondary schools , The teacher put the students who are in the first place and the students who are in the second place . Please write a program to help the teacher finish the assignment automatically , That is, after getting the ranking of the whole class , Among the students who are not currently grouped , Compare the top students with the bottom students opposite sex The students are divided into groups .
Input format :
Enter the first line to give a positive even number N
(≤50), The number of students in the class . thereafter N
That's ok , Give the gender of each student in the order of ranking from high to low (0 On behalf of girls ,1 On behalf of the boy ) And name ( No more than 8 A non empty string of English letters ), In the meantime 1 Space separation . It is guaranteed that the ratio of men to women in this class is 1:1
, And there's no parallel .
Output format :
Output the names of two students in each line , In the meantime 1 Space separation . The high ranking students are in front , The students with lower rank are in the back . The output order of the group is from the top to the bottom according to the ranking of the students in front .
sample input :
8
0 Amy
1 Tom
1 Bill
0 Cindy
0 Maya
1 John
1 Jack
0 Linda
sample output :
Amy Jack
Tom Linda
Bill Maya
Cindy John
AC Code
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
typedef long long ll;
const int N=100010;
struct Student{
int id;
string name;
bool flag;
}student[55];
int main()
{
int n;
cin >> n;
for(int i = 0; i < n; i ++ )
cin >> student[i].id >> student[i].name;
for(int i = 0; i < n / 2; i ++ )
{
cout << student[i].name << ' ';
for(int j = n - 1; j >= n / 2; j -- )
if(student[i].id != student[j].id && student[j].flag != true)
{
cout << student[j].name << endl;
student[j].flag = true;
break;
}
}
return 0;
}
边栏推荐
- Splicing plain text into JSON strings - easy language method
- Blue Bridge Cup Quick sort (code completion)
- 电子协会 C语言 1级 35 、银行利息
- Summary of MySQL common judgment functions!! Have you used it
- BUUCTF(4)
- Zephyr 學習筆記2,Scheduling
- [Chongqing Guangdong education] National Open University spring 2019 770 real estate appraisal reference questions
- 大厂技术专家:架构设计中常用的思维模型
- Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc
- With excellent strength, wangchain technology, together with IBM and Huawei, has entered the annual contribution list of "super ledger"!
猜你喜欢
com. alibaba. nacos. api. exception. NacosException
socket inet_ pton() inet_ Ntop() function (a new network address translation function, which converts the expression format and numerical format to each other. The old ones are inet_aton(), INET_ ntoa
Blog stop statement
Flink memory model, network buffer, memory tuning, troubleshooting
电脑通过Putty远程连接树莓派
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
Solution of running crash caused by node error
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
MySQL中的文本处理函数整理,收藏速查
随机推荐
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
Finishing (III) - Exercise 2
[freertos] freertos Learning notes (7) - written freertos bidirectionnel Link LIST / source analysis
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
Handwritten easy version flexible JS and source code analysis
果果带你写链表,小学生看了都说好
Pangu open source: multi support and promotion, the wave of chip industry
User login function: simple but difficult
Blog stop statement
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
Flink memory model, network buffer, memory tuning, troubleshooting
Text processing function sorting in mysql, quick search of collection
Advanced MySQL: Basics (5-8 Lectures)
Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
What are the work contents of operation and maintenance engineers? Can you list it in detail?
Vulhub vulnerability recurrence 77_ zabbix
神经网络入门(下)
This article is enough for learning advanced mysql
Zephyr study notes 2, scheduling
【森城市】GIS数据漫谈(一)