//poj 2608 还好,差不多水 字符串处理
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
void deal(int a[], int len)
{
int b[25];
int k = 1;
b[0] = a[0];
for(int i = 0; i < len; i++)
{
for(int j = i + 1; j < len; j++)
{
if(a[j] != a[i])
{
b[k++] = a[j];
i = j - 1;
break;
}
}
}
for(int i = 0; i < k; i++)
{
if(b[i] != 0)
cout<<b[i];
}
cout<<endl;
}
int main()
{
string a;
getline(cin, a);
int b[25];
while(!cin.eof())
{
int k = 0;
for(int i = 0; i < a.length(); i++)
{
if(a[i] == 'B' || a[i] == 'F' || a[i] == 'P' ||
a[i] == 'V')
{
b[k++] = 1;
}
else if(a[i] == 'C' || a[i] == 'G' || a[i] ==
'J' || a[i] == 'K' || a[i] == 'Q' || a[i] == 'S' || a[i] == 'X' || a[i]
== 'Z')
{
b[k++] = 2;
}
else if(a[i] == 'D' || a[i] == 'T')
b[k++] = 3;
else if(a[i] == 'L')
b[k++] = 4;
else if(a[i] == 'M' || a[i] == 'N')
b[k++] = 5;
else if(a[i] == 'R')
b[k++] = 6;
else
b[k++] = 0;
}
deal(b, k);
getline(cin, a);
}
return 0;
}
poj 2608
最新推荐文章于 2015-01-10 20:07:49 发布