当前位置:网站首页>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;
}
边栏推荐
- Introduction to spark core components
- Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
- Zephyr Learning note 2, Scheduling
- Routing decorator of tornado project
- Chain ide -- the infrastructure of the metauniverse
- 【FreeRTOS】FreeRTOS學習筆記(7)— 手寫FreeRTOS雙向鏈錶/源碼分析
- The most effective futures trend strategy: futures reverse merchandising
- 两年前美国芯片扭捏着不卖芯片,如今芯片堆积如山祈求中国帮忙
- MySQL中的文本處理函數整理,收藏速查
- Zephyr learning notes 1, threads
猜你喜欢
![[Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)](/img/5c/afb0d43665a8b46579dc604d983790.jpg)
[Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)

Rhcsa day 3

Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool

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

Introduction to rce in attack and defense world
![SQL foundation 9 [grouping data]](/img/8a/a72941d8c3413316b063033a1b5038.jpg)
SQL foundation 9 [grouping data]

Set JTAG fuc invalid to normal IO port

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

Distributed transaction management DTM: the little helper behind "buy buy buy"

With excellent strength, wangchain technology, together with IBM and Huawei, has entered the annual contribution list of "super ledger"!
随机推荐
电子协会 C语言 1级 34 、分段函数
【FreeRTOS】FreeRTOS學習筆記(7)— 手寫FreeRTOS雙向鏈錶/源碼分析
Text processing function sorting in mysql, quick search of collection
kubernetes集群之Label管理
Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?
How to share the source code anti disclosure scheme
Rhcsa the next day
Master-slave replication principle of MySQL database
The important role of host reinforcement concept in medical industry
Pangu open source: multi support and promotion, the wave of chip industry
Directory of tornado
【Kubernetes系列】Kubernetes 上安装 KubeSphere
University stage summary
Research on an endogenous data security interaction protocol oriented to dual platform and dual chain architecture
[freertos] freertos Learning notes (7) - written freertos bidirectionnel Link LIST / source analysis
提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像
Experience installing VMware esxi 6.7 under VMware Workstation 16
果果带你写链表,小学生看了都说好
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
This article is enough for learning advanced mysql