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 hustzh at 2009-02-20 19:58:57 on Problem 1657
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main()
{
	short n;
	cin >> n;
	string s1,s2;
	char x1,y1,x2,y2;
	short a,b = 2,c = 2,d = 2;
	for(int i = 0;i < n;i++)
	{
		cin >> s1 >> s2;
		x1 = s1[0]; y1 = s1[1];
		x2 = s2[0]; y2 = s2[1];
		if(x1 == x2 && y1 == y2)
			cout << "0 0 0 0" << endl;
		else
		{
			a = static_cast<short>(sqrt(static_cast<float>((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))));
			if(x1 == x2 || y1 == y2 || (abs(x1-x2) == abs(y1-y2)))
				b = 1;
			if(x1 == x2 || y1 == y2)
				c = 1;
			cout << a << " " << b << " " << c << " ";
			if(abs(x1-x2)%2 != abs(y1-y2)%2)
				cout << "Inf" << endl;
			else
			{
				if(abs(x1-x2) == abs(y1-y2))
					d = 1;
				cout << d << 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