题解 | #找最小数#
找最小数
https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd
#include <stdio.h> #include <stdlib.h> typedef struct n{ int a; int b; }C; int cmp(const void * c1, const void * c2){ return ((C*)c1)->a - ((C*)c2)->a; } int main() { int n; C c[100]; scanf("%d",&n); for(int i = 0; i < n; i ++){ scanf("%d %d",&c[i].a, &c[i].b); } qsort(c,n,sizeof(C),cmp); int min = c[0].b; int k = c[0].a; for(int i = 0; i < n;i ++){ if(c[i].a == k && c[i].b < min){ min = c[i].b; } } printf("%d %d",k,min); return 0; }