现在的位置: 首页 > 综合 > 正文

poj3096

2019年11月09日 ⁄ 综合 ⁄ 共 346字 ⁄ 字号 评论关闭
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
	int d,l,i,flag;
	string s,tmp;
	while(cin>>s,s!="*")
	{
		flag=1;
		l=s.length();
		for(d=1;flag&&d<l;d++)
		{
			map<string,int>m;
			for(i=0;flag&&i+d<l;i++)
			{
				tmp=s.substr(i,1)+s.substr(i+d,1);
				if(m[tmp]>0)
				{
					cout<<s+" is NOT surprising."<<endl;
					flag=0;
				}
				m[tmp]++;
			}
		}
		if(flag)
		cout<<s+" is surprising."<<endl;
	}
}

抱歉!评论已关闭.