Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
无语的WA,谁帮着找找错啊!!!#include <iostream> #include <cstdlib> using namespace std; struct doll_size{ int w,h; }; int compare(const void *arg1,const void *arg2) { return (* (int *)arg1 < * (int *)arg2) ? -1 : (* (int *)arg1 > * (int *)arg2) ? 1 : 0; } int main() { int nCases,n,i,j; struct doll_size array[20000]; cin >> nCases; while(nCases--){ cin >> n; for(i = 0;i < n;i++) cin >> array[i].w >> array[i].h; qsort(array,n,sizeof(int) * 2,compare); int count = 1; for(i = 1;i < n;i++){ if(array[i].w > array[i - 1].w){ if(array[i].h <= array[i - 1].h) count++; } else{ count++; } } cout << count << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator