题目链接:http://acm.whu.edu.cn/learn/problem/detail?problem_id=1002
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
char c;
char b[8];
int main()
{
int i = 0, sum = 0;
bool flag = false;
bool maohao = true;
bool hang = true;
while((c = getchar()) != EOF)//此处处理全部文本
{
if((c >= '0' && c <= '9'))
{
if(!hang)
{
cout << b << ' ' << sum << endl;
memset(b, 0, sizeof(b));
i = 0;
sum = 0;
maohao = true;
hang = true;
}
b[i++] = c;
}
else if(c == ':')
{
if(maohao)
b[i++] = ':';
maohao = false;
}
else if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '-')
{
if(!flag) sum ++;
flag = true;
}
else
{
flag = false;
hang = false;
}
}
cout << b << ' ' << sum << endl;
return 0;
}