标题:杭电1006为什么不能AC
取消只看楼主
赤壁男儿
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2009-12-26
结帖率:66.67%
 问题点数:0 回复次数:0 
杭电1006为什么不能AC
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;
typedef struct
{
         string name;
         string time;
}ch;
int cmp(const void * a ,const void * b);

int main()
{
     int n;
     ch play[100];
     int k=1;
     while(scanf("%d",&n)&&n)
     {
       int i=0;
       for(i=0;i<n;i++)
         cin>>play[i].name>>play[i].time;
         qsort(play,n,sizeof(ch),cmp);
         cout<<endl<<"Case #"<<k<<endl;
         int j=1;
         for(i=0;i<n;i++)
         {
             if(play[i].time==play[i+1].time)
             {
                cout<<play[i].name<<' '<<j<<endl;
                cout<<play[i+1].name<<' '<<j<<endl;
                i++;
                j=j+2;
             }
             else
             {
                   cout<<play[i].name<<' '<<j<<endl;
                   j++;
                }
         }
         cout<<endl;
         k++;
     }

     system("pause");
     return 0;
}


int cmp(const void * a ,const void * b)
{
     ch * c=(ch *)a;
     ch * d=(ch *)b;
     if(c->time!=d->time)
       return  (*(ch *)c).time<(*(ch *)d).time?-1:1;
    else
    {
         return (*(ch *)c).name<(*(ch *)b).name?-1:1;
     }
}
搜索更多相关主题的帖子: void 1006 include 
2010-11-21 19:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-326422-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.196114 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved