uva live 6481

https://icpcarchive.ecs.baylor.edu/external/64/6481.pdf

把该字符串转化为给定格式,‘;’在第几行就是第几秒。

但有好多坑,样例组数后可能有空格。数据中:后可能没空格,要你自己加

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
#include<cstring>
#include<algorithm>
#define LL long long
#define MOD 100000007
#define INF 0x3f3f3f3f
using namespace std;

const int maxn=305;
queue<char >q;
int cnt,num;
void print()
{
    printf("%d: ",num);
    int x=0;
    while(!q.empty())
    {
        x++;
        char c=q.front();q.pop();
        if(x==3&&c=='Z')printf(" Z");
        else if(c==':')printf(": ");
        else putchar(c);
    }
    printf(";\n");
}
int main()
{
    int T;char ss[10000];
    scanf("%d",&T);gets(ss);
    while(T--)
    {
        while(!q.empty())
            q.pop();
        cnt=0;num=0;
        while(gets(ss))
        {
            ++num;
            if(!strcmp(ss,"END OF CASE"))break;
            int t=strlen(ss);
            for(int i=0;i<t;i++)
            if(ss[i]==' ')continue;
            else if(ss[i]!=';')
            {
                q.push(ss[i]);
            }
            else
            {
                print();
            }
        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值