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> using namespace std; struct wood{ int x; int y; }; void pa(wood a[],int m){ int i,j; for(i=0;i<m-1;i++){ int p=i; for(j=i+1;j<m;j++){ if(a[j].x>a[p].x){ p=j; } if(a[j].x==a[p].x&&a[j].y>a[p].y){ p=j; } } if(p!=i){ wood k; k=a[i];a[i]=a[p];a[p]=k; } } } int main(){ int n,k,m,i;int max; wood a[10000];; cin>>n; while(n>0){ cin>>k; for( i=0;i<k;i++){ cin>>a[i].x>>a[i].y; } pa(a,k);max=-1;m=0; for( i=0;i<k;i++){ cout<<a[i].x<<a[i].y; } for(i=0;i<k;i++){ if(max<a[i].y){ max=a[i].y; m++; } } n--; cout<<m<<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