结构体排序

    xiaoxiao2021-03-25  150

    #include <cstdio> #include <cstdlib> #include <iostream> #include <set> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <cctype> #include <queue> using namespace std; typedef long long ll; struct ha { int x,y; }a[10010]; bool cmp(ha x,ha y) { return x.x<y.x;//升序 } int main() { a[0].x=a[0].y=21; a[1].x=a[1].y=1232; a[2].x=a[2].y=64436; a[3].x=a[3].y=1; sort(a,a+4,cmp); for(int i=0;i<4;i++) cout<<a[i].x<<" "<<a[i].y<<endl; }
    转载请注明原文地址: https://ju.6miu.com/read-7455.html

    最新回复(0)