#include<stdio.h> struct lan { int apple; int pear; int num; }lanzi[100001]; void swap(struct lan a, struct lan b) { struct lan temp; temp.apple = a.apple; temp.pear = a.pear; temp.num = a.num; a.apple = b.apple; a.pear = b.pear; a.num = b.num; b.apple = temp.apple; b.pear = temp.pear; b.num = temp.num; } void sort(struct lan lanzi[], int n) { int i, j; for (i = 0;i < n - 1;i++) { for (j = 0; j < n - 1 - i; j++) { if (lanzi[j].pear < lanzi[j + 1].pear) { swap(lanzi[j], lanzi[j + 1]); } } } for (i = 0;i < n - 1;i++) { for (j = 0; j < n - 1 - i; j++) { if (lanzi[j].apple < lanzi[j + 1].apple) { swap(lanzi[j], lanzi[j + 1]); } } } } int main() { long t, n, m; scanf_s("%ld", &t); for (int i = 0;i < t;i++) { scanf_s("%ld%ld", &n, &m); for (int j = 0;j < n;j++) { scanf_s("%d%d", &lanzi[j].apple, &lanzi[j].pear); lanzi[j].num = j+1; } sort(lanzi, n); for (int k = 0;k < m;k++) { printf("%d", lanzi[k].num); printf(" "); } printf("\n"); } } /* Main.c: In function 'main': Main.c:46:2: warning: implicit declaration of function 'scanf_s' [-Wimplicit-function-declaration] scanf_s("%ld", &t); ^ /tmp/cc1I6CK7.o: In function `main': Main.c:(.text+0x231): undefined reference to `scanf_s' Main.c:(.text+0x257): undefined reference to `scanf_s' Main.c:(.text+0x2ab): undefined reference to `scanf_s' collect2: error: ld returned 1 exit status */ |
Double click to view unformatted code.