比赛 20160707 评测结果 WWWWWWWWWW
题目名称 单词缩写 最终得分 0
用户昵称 PorterCass·D·Ace 运行时间 0.006 s
代码语言 C++ 内存使用 0.51 MiB
提交时间 2016-07-07 15:46:11
显示代码纯文本
#include<cstdio>
#include<cstdlib> 
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
long long t,kk=0;
string s1,s2[50010];
int main()
{
	
	freopen("abbreviation.in","r",stdin);
	freopen("abbreviation.out","w",stdout);
	cin>>t;
	for(long long i=0;i<=t;i++)
	{
		kk++;
		getline(cin,s1);
		for(int j=0;j<s1.size();j++)
		{
			if(s1[j]>='A'&&s1[j]<='Z')
				s1[j]+=32;
		}
		s1[-1]==' ';
		for(int j=0;j<s1.size();j++)
		{
			if(j==0)
			{
				if(s1[j]=='a'&&s1[j+1]=='n'&&s1[j+2]=='d'&&s1[j+3]==' ')s1.erase(j,3);
				if(s1[j]=='f'&&s1[j+1]=='o'&&s1[j+2]=='r'&&s1[j+3]==' ')s1.erase(j,3);
				if(s1[j]=='t'&&s1[j+1]=='h'&&s1[j+2]=='e'&&s1[j+3]==' ')s1.erase(j,3);
			}
			if(s1[j-1]==' '&&s1[j]=='a'&&s1[j+1]=='n'&&s1[j+2]=='d'&&s1[j+3]==' ')
			{
				s1.erase(j,3);
				//j--;
			}
			//cout<<s1<<endl;
			if(s1[j-1]==' '&&s1[j]=='f'&&s1[j+1]=='o'&&s1[j+2]=='r'&&s1[j+3]==' ')
			{
				s1.erase(j,3);
				//j--;
			}
			//cout<<s1<<endl;
			if(s1[j-1]==' '&&s1[j]=='t'&&s1[j+1]=='h'&&s1[j+2]=='e'&&s1[j+3]==' ')
			{
				s1.erase(j,3);
				//j--;
			}
			//cout<<s1<<endl;
			if(s1[j-1]==' '&&s1[j+1]==' ')
			{
				s1.erase(j,1);
			}
			if(s1[j-1]==' '&&s1[j+2]==' ')
			{
				s1.erase(j,2);
			}
		}
		//cout<<s1<<endl;
		if(s1[0]>='a'&&s1[0]<='z')
			s2[kk]+=(char)(s1[0]-32);
		for(int j=1;j<s1.size();j++)
		{
			if(s1[j]>='a'&&s1[j]<='z'&&s1[j-1]==' ')
				s2[kk]+=(char)(s1[j]-32);
		}
	}
	for(int i=1;i<=kk;i++)
		cout<<s2[i]<<endl;
	return 0;
}