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

为什么 Runtime Error

Posted by fantasyorg at 2007-10-16 13:38:56 on Problem 1013
#include<iostream>
#include<cstring>
using namespace std;

int main()
{
	char first[7], second[7], judge[5],
		 left[7], right[7], u_d[5],
		 temp[25], key;
	int times, udMark, lrMark = -1, left_len, right_len, temp_len;
	strcpy(temp, "\0");
	 
	cin >> times;

	for (int i = 0; i < times; i ++)
	{
		for (int j = 0; j < 3; j ++)
		{
			cin >> first >> second >> judge;
			if (strcmp(judge, "even") == 0)
			{
				strcat(temp, first);
				strcat(temp, second);
			}
			else if (strcmp(judge, "up") == 0)
			{
				udMark = 1;
				strcpy(left, first);
				strcpy(right, second);
				left_len = strlen(left);
				right_len = strlen(right);
			}
			else if (strcmp(judge, "down") == 0)
			{
				udMark = 0;
				strcpy(left, first);
				strcpy(right, second);
				left_len = strlen(left);
				right_len = strlen(right);
			}

		}
		temp_len = strlen(temp);

		int sign = 1;
		for (int ii = 0; ii < left_len; ii ++)
		{
			sign = 1;
			for (int jj = 0; jj < temp_len; jj ++)
				if (left[ii] == temp[jj])
					sign = 0;

			if (sign)
			{
				lrMark = 1;
				key = left[ii];
				break;
			}
		}
		if (lrMark == -1)
			for (int iii = 0; iii < right_len; iii ++)
			{
				sign = 1;
				for (int jjj = 0; jjj < temp_len; jjj ++)
					if (right[iii] == temp[jjj])
						sign = 0;

				if (sign)
				{
					lrMark = 0;
					key = right[iii];
					break;
				}
			}
		
		cout << key << " is the counterfeit coin and it is ";
		if (lrMark + udMark == 1)
			cout << "light." << endl;
		else
			cout << "heavy." << 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