Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

菜鸟遇到水题还是很爽的 n62

Posted by songruirui at 2013-03-13 23:11:00 on Problem 3096
#include <memory.h>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
	string str;
	while(cin>>str)
	{
		if(str=="*")
			break;
		else
		{
			int turns=str.length()-1;
			bool flag=false;
			for(int i=1;i<=turns&&flag==false;i++)
			{
				map<string ,int> mmap;
				
				for(int k=0;k+i<=str.length()-1;k++)
				{
					
					char temp[2];
					temp[0]=str[k];
					temp[1]=str[k+i];
					string tempstr(temp);
					tempstr.resize(2);
					mmap[tempstr]++;
					if(mmap[tempstr]!=1)
					{	
						flag=true;
						break;
					}

				}
				
			}
			if(flag==false)
					cout<<str<<" is surprising."<<endl;
			else
					cout<<str<<" is NOT surprising."<<endl;
		}
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator