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 voidman at 2005-12-24 20:57:43 on Problem 1013
#include<stdio.h>
#include<string.h>
	char right[3][7],left[3][7],result[3][10];
int inLeft(int i,char x)
{
	int j,s;
  s=strlen(left[i]);
	for(j=0;j<s;j++)
		if(left[i][j]==x) return 1;
		return 0;
}
int inRight(int i,char x)
{
	int j,p;
	p=strlen(right[i]);
	for(j=0;j<p;j++)
		if(right[i][j]==x) return 1;
		return 0;
}
	int islight(char x)
	{
		int i;
		for(i=0;i<3;i++)
		{
			switch(result[i][0]){
			case 'u':
				if(!inRight(i,x)) return 0;
				break;
			case 'e':
				if(inRight(i,x)||inLeft(i,x)) return 0;
				break;
			case 'd':
				if(!inLeft(i,x)) return 0;
				break;
			}
		}
		return 1;
	}
int isheavy(char x)
	{
		int i;
		for(i=0;i<3;i++)
		{
			switch(result[i][0]){
			case 'u':
				if(!inLeft(i,x)) return 0;
				break;
			case 'e':
				if(inRight(i,x)||inLeft(i,x)) return 0;
				break;
			case 'd':
				if(!inRight(i,x)) return 0;
				break;
			}
		}
		return 1;
	}



void main(){
	int i,n;
	scanf("%d",&n);
	for(i=0;i<3;i++)
	{
		
		
			scanf("%s%s%s",left[i],right[i],result[i]);
		
		
	}
	for(char c='A';c<='L';c++)
	{
		if(islight(c))
		{
			printf("%c is the counterfeit coin and it is light.\n",c);
			break;
		}
		else if(isheavy(c))
		{
			printf("%c is the counterfeit coin and it is heavy.\n",c);
			break;
		}
	}
}

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