当前位置:网站首页>1182: effets de la photo de groupe
1182: effets de la photo de groupe
2022-06-28 09:07:00 【Singe de programme qui frappe le clavier】
1182:Effet de la photo de groupeDélais: 1000 ms Limite de mémoire: 65536 KB Nombre de communications: 19707 Nombre de passes: 11284 【Description du sujet】Xiao Yun et ses amis sont allés escalader la montagne parfumée,Fasciné par la beauté du paysage,Je veux prendre une photo de groupe..S'ils se tenaient en ligne,,Les garçons sont à gauche.(Du point de vue du photographe),Et de gauche à droite dans l'ordre de bas en haut,Toutes les filles sont à droite.,Et de gauche à droite dans l'ordre de haut en bas,Quel est l'effet de leur photo de groupe?(Tout le monde a une taille différente.)? 【Entrée】La première ligne est le nombre de personnesn(2 <= n <= 40,Et au moins1Un garçon et1Une fille). Juste derrièrenD'accord,Entrez le sexe d'une personne par ligne(HommesmaleOu femmesfemale)Et la taille(Nombre de points flottants,Unit é m),Deux données séparées par des espaces. 【Produits】nNombre de points flottants,Après la simulation,La taille de tout le monde de gauche à droite dans les yeux du photographe.Chaque point flottant doit être maintenu après le point décimal2Bits,.Les deux nombres adjacents sont séparés par un seul espace. 【Exemple d'entrée】6
male 1.72
male 1.78
female 1.61
male 1.65
female 1.70
female 1.56【Exemple de sortie】1.65 1.72 1.78 1.70 1.61 1.56 |
【Idées】
EtQuestion précédenteC'est pareil, Trier les chaussures pour enfants en hommes et en femmes .
【CECode】
#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;
}
【RECode】
#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;
}
【ACCode】
#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;//Détermination du sexe
else c[y++]=a[i].m;//Enregistrer dans le tableau
}
for(int i=0;i<x;i++)//Trier
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;
}

边栏推荐
- 手机买同业存单基金开户选哪家证券公司比较好,比较安全呢
- Calculation of stock purchase and sale expenses
- 如何抑制SiC MOSFET Crosstalk(串擾)?
- Characteristics and prevention of electrical fire
- Analysis of prepaid power purchase device
- [.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
- Loggerfactory uses log4j Parameter introduction of properties
- Implementation of single sign on
- Batch modify tables and sorting rules for fields in tables
- 从知识到智慧:知识图谱还要走多远?
猜你喜欢

为什么SELECT * 会导致查询效率低?

Import and export of a single collection in postman

【大案例】学成在线网站

How to suppress SiC MOSFET crosstalk?

Calcul des frais d'achat et de vente d'actions

SQL 優化經曆:從 30248秒到 0.001秒的經曆

Valentine's Day - VBS learning (sentences, love words)

new URL(“www.jjj.com“)

SQL 优化经历:从 30248秒到 0.001秒的经历

STL -- binder
随机推荐
Data modeling based on wide table
Ffmpeg streaming fails to update header with correct duration
Basic operation of PMP from applying for the exam to obtaining the certificate, a must see for understanding PMP
redis5.0的槽点迁移,随意玩(单机迁移集群)
手机买同业存单基金开户选哪家证券公司比较好,比较安全呢
"Jianzhi offer" -- Interview Question 4: finding two-dimensional arrays
rman备份报ORA-19809 ORA-19804
Data mining modeling practice
Common test method used by testers --- orthogonal method
【无标题】
From knowledge to wisdom: how far will the knowledge map go?
如何实现基于 RADIUS 协议的双因子认证 MFA?
Find the total number of 1 appearing in the integer 1-N and the number of 1 in the binary of the integer
Explain observer mode
How do individuals open accounts to speculate in stocks? Is online account opening safe?
Postman interface test
Power data
【云原生 | Kubernetes篇】深入了解Pod(六)
APICloud携手三六零天御,助力企业守好App安全“第一关”
Using transform:scale causes the page mouse hover event to disappear