Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
晕!哪位高人帮忙看一下,在自己机器上运行可以的,现在是Wrong Answer,谢谢了。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator