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

晕!哪位高人帮忙看一下,在自己机器上运行可以的,现在是Wrong Answer,谢谢了。

Posted by cpp0600548257 at 2006-02-22 20:20:36 on Problem 1657
#include<iostream.h>
#include<math.h>
#include<iomanip.h>
void main()
{
    int i;
	int amount,startc,startn,endc,endn;
	int king[20],queen[20],car[20],leader[20];
    char data[2];
	cin>>amount;
	for (i=0;i<amount;i++)
	{
		cin>>data;                //输入都用整形,因为字母差的和数字差的一样长嘛
		startc=*data;
		startn=*(data+1);
		cin>>data;
		endc=*(data);
		endn=*(data+1);
        if (endn-startn==0&&endc-startc==0) //起终一样
		{
			king[i]=0; queen[i]=0;car[i]=0; leader[i]=0;
		}
		else 
		{
			if (abs(endn-startn)==abs(endc-startc)||endn-startn==0||endc-startc==0) //横竖斜
			{
				queen[i]=1;
			}
			else 
			{
				queen[i]=2;
			}
			if (endn-startn==0||endc-startc==0)  //横竖
			{
				car[i]=1;
			}
			else
			{
				car[i]=2;
			}
			if (abs(endn-startn)>abs(endc-startc))  //横和竖差的最多的一个
			{
				king[i]=abs(endn-startn);
			}
			else 
			{
				king[i]=abs(endc-startc);
			}
			if (abs(endn-startn)%2==abs(endc-startc)%2)  //可以到的
			{
				leader[i]=abs(abs(endn-startn)-abs(endc-startc))/2+1;
			}
			else
			{
				leader[i]=-1;
			}
		}
	}
	for (i=0;i<amount;i++)
	{
		cout<<king[i]<<setw(2)<<queen[i]<<setw(2)<<car[i];
		if (leader[i]==-1)  cout<<setw(2)<<" Inf"<<endl;
		else cout<<setw(2)<<leader[i]<<endl;
	}
}

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