// a.cpp : Defines the entry point for the console application.// #include "stdafx.h" #include <iostream.h>#include <stdlib.h> //int X[10000],Y[10000],n; /*struct P{ int x1; int x2;}a[10000]; int comp(const void *a,const void *b){ struct P *x=(P *)a; struct P *y=(P *)b; if(x->x1>y->x1) return 0; else if(x->x1<y->x1) return 1; else { if(x->x2>y->x2) return 0; } return 1;} */struct In { int x; int y; }a[100]; int cmp( const void *a , const void *b ) { struct In *c = (In *)a; struct In *d = (In *)b; if(c->x != d->x) return c->x - d->x; else return c->y - d->y; } int MaxVisitors(int X[], int Y[], int n){ int main(){ int i,n; cin>>n; for(i=0;i<n;i++) cin>>a[i].x>>a[i].y; qsort(a,n,sizeof(a[0]),cmp); MaxVisitors(int X[], int Y[], int n) for(i=0;i<n;i++) cout<<a[i].x<<" "<<a[i].y<<endl;} PS:写程序的草稿而已!

评论