当前位置:网站首页>1182: group photo effect
1182: group photo effect
2022-06-28 09:07:00 【A program ape who smashes the keyboard】
1182: Group photo effectThe time limit : 1000 ms Memory limit : 65536 KB Submission number : 19707 Passing number : 11284 【 Title Description 】Xiao Yun and his friends went to climb Xiangshan , Intoxicated by the beautiful scenery , Take a group photo . If they stand in a row , All the boys are on the left ( From the perspective of the photographer ), And in the order from low to high, from left to right , All the girls are on the right , And in the order from high to low, from left to right , What is the effect of their group photo ( Everyone is different in height )? 【 Input 】The first line is the number of people n(2 <= n <= 40, And at least there is 1 A boy and 1 A girl ). Follow closely behind n That's ok , Enter a person's gender on each line ( male male Or female female) And height ( Floating point numbers , Unit meter ), The two data are separated by spaces . 【 Output 】n A floating point number , After the simulation stands in line , The height of everyone from left to right in the eyes of the photographer . Each floating-point number should be kept after the decimal point 2 position , Two adjacent numbers are separated by a single space . 【 sample input 】6
male 1.72
male 1.78
female 1.61
male 1.65
female 1.70
female 1.56【 sample output 】1.65 1.72 1.78 1.70 1.61 1.56 |
【 Ideas 】
and Last question equally , Just sort the children's shoes into men and women .
【CE Code 】
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int N=1e5+10;
inline int fread()
{
char ch=getchar();
int n=0,m=1;
while(ch<'0' or ch>'9')
{
if(ch=='-')m=-1;
ch=getchar();
}
while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-48,ch=getchar();
return n*m;
}
int n,x,y;
double b[N],c[N];
struct node
{
double m;
char ch[N];
}a[N];
void _sort()
{
for(int i=0;i<x;i++)
for(int j=i+1;i<x;j++)
if(b[i]>b[j])swap(b[i],b[j]);
for(int i=0;i<y;i++)
for(int j=i+1;j<y;j++)
if(c[i]<c[j])swap(c[i],c[j]);
}
signed main()
{
n=fread();
for(int i=0;i<n;i++)
{
cin>>a[i].ch>>a[i].m;
if(strcmp(a[i].ch,"male")==0)b[x++]=a[i].m;
else c[y++]=a[i].m;
}
_sort();
for(int i=0;i<x;i++)cout<<fixed<<setprecision(2)<<b[i];
for(int i=0;i<y;i++)cout<<fixed<<setprecision(2)<<c[i];
return 0;
}
【RE Code 】
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int N=1e5+10;
inline int fread()
{
char ch=getchar();
int n=0,m=1;
while(ch<'0' or ch>'9')
{
if(ch=='-')m=-1;
ch=getchar();
}
while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-48,ch=getchar();
return n*m;
}
int n,x,y;
double b[N],c[N];
struct node
{
double m;
char ch[20];
}a[N];
void _sort()
{
for(int i=0;i<x;i++)
for(int j=i+1;i<x;j++)
if(b[i]>b[j])swap(b[i],b[j]);
for(int i=0;i<y;i++)
for(int j=i+1;j<y;j++)
if(c[i]<c[j])swap(c[i],c[j]);
}
signed main()
{
n=fread();
for(int i=0;i<n;i++)
{
cin>>a[i].ch>>a[i].m;
if(strcmp(a[i].ch,"male")==0)b[x++]=a[i].m;
else c[y++]=a[i].m;
}
_sort();
for(int i=0;i<x;i++)cout<<fixed<<setprecision(2)<<b[i];
for(int i=0;i<y;i++)cout<<fixed<<setprecision(2)<<c[i];
return 0;
}
【AC Code 】
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int N=45;
inline int fread()
{
char ch=getchar();
int n=0,m=1;
while(ch<'0' or ch>'9')
{
if(ch=='-')m=-1;
ch=getchar();
}
while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-48,ch=getchar();
return n*m;
}
int n,x,y;
double b[N],c[N];
struct node
{
double m;
char ch[N];
}a[N];
signed main()
{
n=fread();
for(int i=0;i<n;i++)
{
cin>>a[i].ch>>a[i].m;
if(strcmp(a[i].ch,"male")==0)b[x++]=a[i].m;// Determine gender
else c[y++]=a[i].m;// Put it in an array
}
for(int i=0;i<x;i++)// Sort
for(int j=i+1;j<x;j++)
if(b[i]>b[j])
swap(b[i],b[j]);
for(int i=0;i<y;i++)
for(int j=i+1;j<y;j++)
if(c[i]<c[j])
swap(c[i],c[j]);
for(int i=0;i<x;i++)cout<<fixed<<setprecision(2)<<b[i]<<" ";
for(int i=0;i<y;i++)cout<<fixed<<setprecision(2)<<c[i]<<" ";
return 0;
}

边栏推荐
- 【云原生 | Kubernetes篇】深入了解Pod(六)
- containerd1.5.5的安装
- Applet: traverse the value of an array in the list, which is equivalent to for= "list" list An item in comment
- Which is a better ERP management system for electronic component sales?
- Discussion on safety management of centralized maintenance construction site of substation under the mode of operation and maintenance
- Goldbach`s Conjecture
- Lilda low code data large screen, leveling the threshold of data application development
- [.Net6] GRP server and client development cases, as well as the access efficiency duel between the minimum API service, GRP service and traditional webapi service
- Apache Doris 成为 Apache 顶级项目
- APICloud携手三六零天御,助力企业守好App安全“第一关”
猜你喜欢

Implementation of code scanning login

买卖股票费用计算

spark的资源调度和任务调度
![[untitled]](/img/bb/213f213c695795daecb81a4cf2adcd.jpg)
[untitled]

MySQL8.0 忘记 root 密码

DEJA_VU3D - Cesium功能集 之 051-地形开挖完美实现

Basic knowledge of hard disk (head, track, sector, cylinder)

Discussion on the practice of fire emergency lighting system in the field of building electrical design

使用transform:scale之后导致页面鼠标悬浮事件消失

Matlab tips (20) matrix analysis -- principal component regression
随机推荐
Privacy computing fat----- offline prediction
Copy & Deepcopy
JMeter -- interface test 2
股票 停牌
Basic knowledge of hard disk (head, track, sector, cylinder)
个人究竟如何开户炒股?在线开户安全么?
从知识到智慧:知识图谱还要走多远?
为什么SELECT * 会导致查询效率低?
Stock suspension
Resource scheduling and task scheduling of spark
Music website design based on harmonyos (portal page)
Implementation of single sign on
【无标题】
【云原生 | Kubernetes篇】深入了解Pod(六)
Rich text - Test Case
temple
What are the advantages of a differential probe over a conventional probe
小程序 :遍历list里面的某个数组的值,等同于 for=“list” list.comment里面的某一项
new URL(“www.jjj.com“)
电子元器件销售ERP管理系统哪个比较好?