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

Re:我这程序总是出现编译错误,哪位好信人帮忙看一看,搞不定啊,为什么中出现编译错误

Posted by zjwlacm at 2008-07-12 17:17:00 on Problem 1013
In Reply To:我这程序总是出现编译错误,哪位好信人帮忙看一看,搞不定啊,为什么中出现编译错误 Posted by:acm_primer2007 at 2007-10-07 12:58:38
> #include <iostream>
> #include <string>
> using namespace std;
> 
> char left[3][7],right[3][7],result[3][7];
> bool inLeft(int i, char x);
> bool inRight(int i, char x);
> bool isLight(char x);
> bool isHeavy(char x);
> 
> void main()
> {
> 
> 	int n,i,j;
> 	cin>>n;
> 	
> 	for( i = 0; i < n; i++)
> 	{		
> 		for( j = 0; j < 3 ;j++){	//输入3次balance左右两边的值
> 			cin>>left[j]>>right[j]>>result[j];
> 		}
> 	
> 	
> 		for(char c='A'; c<='L'; c++)
> 			if( isLight(c) )
> 			{
> 				cout << c << " is the counterfeit coin and it is light.\n";
> 				break;
>         
> 			}
> 			
> 			else if( isHeavy(c) )
> 			{
> 				cout << c << " is the counterfeit coin and it is heavy.\n";
> 				break;
> 			}
> 
> 	}
> }
> 
> bool inLeft(int i, char x)
> {
> 	int j;
> 	for(j=0; j<strlen(left[i]); j++) 
> 		if(left[i][j] == x ) return true;
> 		return false;                  
> }
> 
> bool inRight(int i, char x)
> {
> 	int j;
> 	for(j=0; j<strlen(right[i]); j++) 
> 		if(right[i][j]== x) return true;
> 		return false;                  
> }
> 
> 
> bool isLight(char x)		//轻
> {
> 	int i;
> 	for(i=0; i<3; i++)
> 		switch( result[i][0] ) 
> 	{
> 		   case 'u': if( ! inRight(i,x) )  return false;	//右边up了,但x不在右边,说明x不是轻
> 			   break;
> 		   case 'e': if(inRight(i,x) || inLeft(i,x))  return false;	//x在左或在右,但却平衡,说明x不是轻
> 			   break;
> 		   case 'd': if(! inLeft(i,x))  return false;		//右边down了,但x不在左边,说明x不是轻
> 			   break;
> 	}
> 	return true;
> }
> 
> bool isHeavy(char x)	//x为重,和轻得情况类似
> {
> 	int i;
> 	for(i=0; i<3; i++)
> 		switch( result[i][0] ) 
> 	{
>        case 'u': if( ! inLeft(i,x) )  return false;
> 		   break;
>        case 'e': if(inRight(i,x) || inLeft(i,x))  return false;
> 		   break;
>        case 'd': if(! inRight(i,x))  return false;
> 		   break;
>     }
> 	return true;
> }
> 
> 
> 

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