题解 | #找最小数#
找最小数
https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd
#include <bits/stdc++.h> using namespace std; class node{ public: int x; int y; }; bool cmp(node n1, node n2){ if(n1.x!=n2.x)return n1.x<n2.x; return n1.y<n2.y; } int main() { int n;cin>>n; node arr[n]; for(int i =0;i<n;i++){ int x,y; cin>>x>>y; node p; p.x = x; p.y = y; arr[i] = p; } sort(arr,arr+n,cmp); cout<<arr[0].x<<" "<<arr[0].y<<endl; } // 64 位输出请用 printf("%lld")
能用stl从不写代码