当前位置:网站首页>862. triple sorting
862. triple sorting
2022-06-23 02:24:00 【Twilight lattice】
Catalog
One 、 Problem description
Given N A triad (x,y,z), among x Is an integer ,y Is a floating point number ,z Is string .
Please follow x Print these triples in descending order .
Data guarantees different triples x The values are different from each other .
Input format
The first line contains integers N.
Next N That's ok , Each line contains an integer x, A floating point number y, A string z, Represents a triple , The three are separated by a space .
Output format
common N That's ok , according to x Order from small to large , Each line outputs a triple .
Be careful , Floating point numbers for all inputs and outputs y Keep two decimal places .
Data range
1≤N≤10000,
1≤x,y≤105,
The total length of the string does not exceed 105.
sample input :
5
32 1.36 nsyiupnnhc
18 4.53 fmofzwrah
33 4.86 wzuymbm
1 3.93 gtnrwcebt
31 4.53 gcllxioc
sample output :
1 3.93 gtnrwcebt
18 4.53 fmofzwrah
31 4.53 gcllxioc
32 1.36 nsyiupnnhc
33 4.86 wzuymbmTwo 、 Problem solving
1. Code
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
class Triples
{
public:
int x;
float y;
string z;
};Triples th[10010];
bool comp(Triples a, Triples b)
{
return a.x < b.x;
}
int main()
{
int n;
cin >> n;
for(int i = 0; i < n ; i++)
cin >> th[i].x >> th[i].y >> th[i].z;
sort(th,th+n,comp);
for (int i = 0; i < n; i ++) printf("%d %.2f %s\n", th[i].x, th[i].y, th[i].z.c_str());
return 0;
}边栏推荐
- Schedule tasks to periodically restart remote services or restart machines
- How to make word notes beautiful
- 5g spectrum
- This monitoring tool is enough for the operation and maintenance of small and medium-sized enterprises - wgcloud
- Spark broadcast variables and accumulators (cases attached)
- Circuit analysis (circuit principle)
- Salesforce fileUpload (I) how to configure the file upload function
- My good brother gave me a difficult problem: retry mechanism
- Get the structure of the class through reflection, little chestnut
- Stop automatically after MySQL starts (unable to start)
猜你喜欢

Analog Electronic Technology

1.3-1.4 web page data capture
![Buuctf misc-[bjdctf2020] Nani](/img/4e/ac6bf2f64cb68136581814da73db66.jpg)
Buuctf misc-[bjdctf2020] Nani

Performance test -- 14 detailed explanation of performance test report and precautions

Lying in the trough, write it yourself if you can't grab it. Use code to realize a Bing Dwen Dwen. It's so beautiful

2021-11-11

1. Mx6u bare metal program (4) - GPIO module

Common mistakes in C language (sizeof and strlen)

Application and challenge of ten billion level map data in Kwai security intelligence

Third order magic cube formula
随机推荐
Troubleshooting and optimization of easynvr version 5.0 Video Square snapshot not displayed
Hypervisor Necromancy; Recover kernel protector (2)
Pychart installation instructions
Dynamic address book in C language (add, delete, modify, check (duplicate), delete, sort and export)
Lying in the trough, write it yourself if you can't grab it. Use code to realize a Bing Dwen Dwen. It's so beautiful
Log a log4j2 vulnerability handling
Campus network AC authentication failed
Deep scan log4j2 vulnerability using codesec code audit platform
Rebirth -- millimeter wave radar and some things I have to say
Nfv and SDN
Performance test -- 14 detailed explanation of performance test report and precautions
Performance testing -- Interpretation and practice of 16 enterprise level project framework
Evolution history of mobile communication
1.3-1.4 web page data capture
//1.17 printf function
Function part
Operator part
Phpexcel export with picture Excel
Mobile communication Overview - Architecture
Three methods for solving Fibonacci sequence feibonacci (seeking rabbit) - program design