当前位置:网站首页>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;
}

边栏推荐
猜你喜欢

【大案例】学成在线网站

redis5.0的槽点迁移,随意玩(单机迁移集群)

Which is a better ERP management system for electronic component sales?

How to solve the problem of high concurrency and seckill

学习阿里如何进行数据指标体系的治理

罗氏线圈工作原理

Explain observer mode

STL - inverter
![[cloud native | kubernetes] in depth understanding of pod (VI)](/img/ae/f16f5c090251ab603b88ddadff7eb3.png)
[cloud native | kubernetes] in depth understanding of pod (VI)

new URL(“www.jjj.com“)
随机推荐
Import and export of a single collection in postman
实现全局双指长按返回桌面
Illustration of MySQL binlog, redo log and undo log
Construire le premier réseau neuronal avec pytorch et optimiser
Basic content learning of software testing (I)
DEJA_ Vu3d - 051 of cesium function set - perfect realization of terrain excavation
Rman Backup Report Ora - 19809 Ora - 19804
从知识到智慧:知识图谱还要走多远?
Installation of containerd1.5.5
Three body attack (three-dimensional split plus two points)
Scenario method and error recommendation method for learning basic content of software testing (2)
玩玩sftp上传文件
数据挖掘建模实战
Discussion on the improvement and application of the prepayment system in the management of electricity charge and price
学习阿里如何进行数据指标体系的治理
【云原生 | Kubernetes篇】深入了解Pod(六)
Fire fighting work and measures in Higher Vocational Colleges
Is it safe for CICC fortune to open an account? How much do you charge?
How to solve the problem of high concurrency and seckill
Mysql8.0 forgot the root password