当前位置:网站首页>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;
}
边栏推荐
- MySQL 数据库 - 函数 约束 多表查询 事务
- tornado项目之路由装饰器
- Node foundation ~ node operation
- Rhcsa the next day
- CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
- Take you to master the formatter of visual studio code
- In the era of low code development, is it still needed?
- Industrial computer anti-virus
- The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
- One of the general document service practice series
猜你喜欢

BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment

win10微软拼音输入法输入文字时候下方不出现中文提示

The most effective futures trend strategy: futures reverse merchandising

深入浅出:了解时序数据库 InfluxDB

果果带你写链表,小学生看了都说好

Transition technology from IPv4 to IPv6

Two years ago, the United States was reluctant to sell chips, but now there are mountains of chips begging China for help

Deep profile data leakage prevention scheme

手写简易版flexible.js以及源码分析

Go learning notes - constants
随机推荐
Rhcsa the next day
[FreeRTOS] FreeRTOS learning notes (7) - handwritten FreeRTOS two-way linked list / source code analysis
2022 - 021arts: début du deuxième semestre
Blue Bridge Cup Quick sort (code completion)
kubernetes集群之Label管理
Guoguo took you to write a linked list, and the primary school students said it was good after reading it
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
Zephyr study notes 2, scheduling
Zephyr 學習筆記2,Scheduling
《剑指Offer》第2版——力扣刷题
The most effective futures trend strategy: futures reverse merchandising
Electronic Association C language level 1 34, piecewise function
【FreeRTOS】FreeRTOS学习笔记(7)— 手写FreeRTOS双向链表/源码分析
Industrial computer anti-virus
Label management of kubernetes cluster
Solution of running crash caused by node error
手写简易版flexible.js以及源码分析
win10微软拼音输入法输入文字时候下方不出现中文提示
Status of the thread
[C language] open the door of C