题目描述
blablabla
样例
blablabla
C++ 代码
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
struct Node{
int x;
double y;
char z[256];
bool operator<(const Node& ps)const{
if(this->x<ps.x)
return true;
else
return false;
}
};
int main(){
int n;
cin>>n;
Node nodes[n];
for (int i = 0; i < n; ++i) {
int x;
double y;
char z[256];
cin>>x>>y>>z;
nodes[i].x=x;
nodes[i].y=y;
memcpy(nodes[i].z,z,sizeof(z));
}
sort(nodes,nodes+n);
for (int i = 0; i < n; ++i) {
cout<<nodes[i].x<<" ";
printf("%.2f",nodes[i].y);
cout<<" "<<nodes[i].z<<endl;
}
return 0;
}
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度分析:blablabla
C++ 代码
blablabla