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

实在想不出哪错了,哪位大牛帮忙看一下吧

Posted by PhillipLee at 2004-12-18 17:21:39 on Problem 1250
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n;
	while(1)
	{
		cin>>n;
		if(n==0) break;
		string s;
		cin>>s;
		int count=0;
		int total=0;
		char bed[20];
		
		for(int i=0;i<s.length();i++)
		{
			int nFlag=0;
			for(int j=0;j<count;j++)
			{
				if(bed[j]==s[i])
				{
					for(int k=j;k<count-1;k++)
					{
						bed[j]=bed[j+1];
					}
					nFlag=1;
					count--;
					break;
				}
			}
			if(nFlag==0 && count<n) 
			{
				bed[count]=s[i];
				count++;
			}
			else if(nFlag==0 && count==n) total++;
		}
		if(total==0) cout<<"All customers tanned successfully."<<endl;
		else cout<<total/2<<" customer(s) walked away."<<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