当前位置:网站首页>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
- Summary of MySQL common judgment functions!! Have you used it
- Computer connects raspberry pie remotely through putty
- 2022-021ARTS:下半年開始
- A real penetration test
- 手写简易版flexible.js以及源码分析
- Enter the year, month, and determine the number of days
- One of the general document service practice series
- Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
- window上用.bat文件启动项目
猜你喜欢
![[C language] open the door of C](/img/e0/2f107966423d6492c39995c77a445e.jpg)
[C language] open the door of C

Summary of MySQL common judgment functions!! Have you used it

The crackdown on Huawei prompted made in China to join forces to fight back, and another enterprise announced to invest 100 billion in R & D

Rhcsa day 3

时序数据库 InfluxDB 2.2 初探

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

Blog stop statement

Deep profile data leakage prevention scheme

Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!

"Sword finger offer" 2nd Edition - force button brush question
随机推荐
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
深入浅出:了解时序数据库 InfluxDB
Knowledge payment applet dream vending machine V2
Oceanbase is the leader in the magic quadrant of China's database in 2021
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
Crawler (III) crawling house prices in Tianjin
【Kubernetes系列】Kubernetes 上安装 KubeSphere
神经网络入门(下)
With excellent strength, wangchain technology, together with IBM and Huawei, has entered the annual contribution list of "super ledger"!
Transition technology from IPv4 to IPv6
Detailed introduction to the big changes of Xcode 14
jdbc连接es查询的时候,有遇到下面这种情况的大神嘛?
Data double write consistency between redis and MySQL
输入年份、月份,确定天数
Zephyr Learning note 2, Scheduling
用于压缩视频感知增强的多目标网络自适应时空融合
kubernetes集群之Label管理
How to send mail with Jianmu Ci
Chapter 1 programming problems