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 chengmingvictor at 2005-08-25 16:09:38 on Problem 1867
#include <iostream>
#include <memory>
#include <stack>
#include <string>
using namespace std;

const int MAX_SIZE = 26;
int adj[2][MAX_SIZE][MAX_SIZE];
int size[2];

int input(int a[][MAX_SIZE])
{
	stack<int> root;
	char ch;
	memset(a, 0, sizeof(int) * MAX_SIZE * MAX_SIZE);
	int temp, size = 0;
	while(cin.get(ch) && ch != '\n')
	{
		if(ch <= 'Z' && ch >= 'A')
		{
			temp = ch - 'A';
			if(temp + 1 > size)
				size = temp + 1;
			if(root.size())
				a[root.top()][temp] = a[temp][root.top()] = 1;
		}
		else if(ch == '(')
			root.push(temp);
		else if(ch == ')')
			root.pop();
	}
	return size;
}

bool same()
{
	for(int i = 0; i < size[0]; i++)
		for(int j = 0; j < size[0]; j++)
			if(adj[0][i][j] != adj[1][i][j])
				return false;
	return true;
}

int main()
{
	int c;
	cin>>c;
	cin.get();
	while(c--)
	{
		size[0] = input(adj[0]);
		size[1] = input(adj[1]);
		bool equ = true;
		if(size[0] == size[1] && same())
			cout<<"same"<<endl;
		else cout<<"different"<<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