【W】HDU1084——排序

http://acm.hdu.edu.cn/showproblem.php?pid=1084

这道题就不多说了,有时间再去咪它~~

 

#include<stdio.h> #include<string> #include<algorithm> using namespace std; struct Student { int num; char time[10]; int flg; }; Student s1[105],s2[105]; int N; bool cmp(Student m1,Student m2) { if(m1.num>m2.num)return true; else if(m1.num<m2.num)return false; else { if(strcmp(m1.time,m2.time)<0)return true; else return false; } } bool Injuge(int num,int i) { int j,start,end,index; bool x=true; for(j=0;j<N;j++) { if(s2[j].num==num&&x) { start=j; x=false; continue; } if(s2[j].num==num&&s2[j].flg==i) { index=j; continue; } if(s2[j].num!=num&&!x) { end=j; x=true; break; } } if(!x)end=j-1; if((start+end)%2!=0) { if(index<=(start+end)/2)return true; else return false; } else { if(index<(start+end)/2)return true; else return false; } } int main() { int i; while(scanf("%d",&N)!=-1) { for(i=0;i<100;i++) { s2[i].num=s1[i].num=0; memset(s1[i].time,0,sizeof(s1[i].time)); memset(s2[i].time,0,sizeof(s2[i].time)); s2[i].flg=s1[i].flg=0; } for(i=0;i<N;i++) { scanf("%d %s",&s1[i].num,s1[i].time); s2[i].num=s1[i].num; strcpy(s2[i].time,s1[i].time); s2[i].flg=s1[i].flg=i; } sort(s2,s2+N,cmp); //第二个参数要指向最后一个元素的下一个位置 for(i=0;i<N;i++) { switch(s1[i].num) { case 5:printf("100/n");continue;break; case 4:if(Injuge(s1[i].num,i))printf("95/n");else printf("90/n");break; case 3:if(Injuge(s1[i].num,i))printf("85/n");else printf("80/n");break; case 2:if(Injuge(s1[i].num,i))printf("75/n");else printf("70/n");break; case 1:if(Injuge(s1[i].num,i))printf("65/n");else printf("60/n");break; case 0:printf("50/n");continue;break; default:printf("input error");break; } } printf("/n"); } return 0; }

 

你可能感兴趣的:(ini,input)