背景:创建结构体,有x,y,z三个元素,需要将结构体数组按元素z从小到大排步骤:1.创建结构体struct stu{ int x; int y; int z; bool operator<(const stu &other)const{ return z < other.z; }} a[100];2.赋值for(int i = 1; i <= n; i++){ cin >> a[i].x >> a[i].y >> a
摘要由CSDN通过智能技术生成
背景:创建结构体,有x,y,z三个元素,需要将结构体数组按元素z从小到大排
步骤:
1.创建结构体
struct stu{
int x;int y;int z;
bool operator<(const stu &other)const{
return z < other.z
背景:创建结构体,有x,y,z三个元素,需要将结构体数组按元素z从小到大排步骤:1.创建结构体struct stu{ int x; int y; int z; bool operator<(const stu &other)const{ return z < other.z; }} a[100];2.赋值for(int i = 1; i <= n; i++){ cin >> a[i].x >> a[i].y >> a