#include<stdio.h> void quickSort(int a[], int b[],int low, int high) {     int i = low, j = high, temp =a[low],temp2=b[low];     if (low > high) {         return;     }     while (i!=j)     {         while (i<j&&a[j]>=temp)         {             j--;         }         while (i<j&&a[i]<=temp)         {             i++;         }         if (i < j) {             int t = a[i];             a[i] = a[j];             a[j] = t;             t = b[i];             b[i] = b[j];             b[j] = t;         }     }     a[low]= a[i];     b[low] = b[i];     b[i] = temp2;     a[i] = temp;     quickSort(a,b ,low, i - 1);     quickSort(a, b,i + 1, high); } int main() {     int n;     int wa[1000], ha[1000];     int w, h;     scanf_s("%d", &n);     for (int i = 0; i < n; i++) {         scanf_s("%d%d", &w, &h);         wa[i]= w;         ha[i]= h;     }     quickSort(wa,ha,0, n-1);     int i = 0;     int count =1;     for (int j = i + 1; j < n; j++) {         if (wa[i] < wa[j] && ha[i] < ha[j]) {             count++;             i = j;         }     }     printf("%d\n", count); }
点赞 1

相关推荐

02-22 21:16
已编辑
门头沟学院 运营
点赞 评论 收藏
分享
牛客网
牛客企业服务