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

WA!求助!

Posted by elephantmic at 2007-05-28 12:37:10 on Problem 2328
打了个表,high为1,low为-1,如果right on的数为0 且它左边没有1右边没有-1则正确
不明白为什么错了!
求助!


#include<iostream.h>

int main()
{
	int a[11];
	char s[12];
	int i,j,k,n,flag=1;
	for(i=0;i<11;i++)a[i]=0;
	while(cin>>n && n!=0)
	{
		cin.ignore();
		cin.getline(s,10);
		if(s[4]=='t')
		{
			for(i=1;i<=10;i++) 
				if ((i>n && a[i]==-1) || (i<n && a[i]==1) || a[n]!=0)
				{
					flag=0;break;
				}
			if(flag==0)cout<<"Stan is dishonest"<<endl;
			else cout<<"Stan may be honest"<<endl;
			flag=1;
			for(i=0;i<11;i++)a[i]=0;
		}
		else if(s[4]=='h') if(a[n]==0)a[n]=1;else flag=0;
		else if(s[4]=='l') if(a[n]==0)a[n]=-1;else flag=0;
	}
	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