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> void wang(char a,char b,char c,char d){ int g; int i=a-c; int j=b-d; if((int)fabs(i)>(int)fabs(j)) g=(int)fabs(i); else g=(int)fabs(j); cout<<g<<" "; } void hou(char a,char b,char c,char d){ int i=a-c; int j=b-d; int k=(int)fabs(i)-(int)fabs(j); if(k==0||i==0||j==0) cout<<"1 "; else cout<<"2 "; } void che(char a,char b,char c,char d){ int i=a-c; int j=b-d; if(i==0||j==0) cout<<"1 "; else cout<<"2 "; } void xiang(char a,char b,char c,char d){ int i=a-c; int j=b-d; if((i%2)!=(j%2)) cout<<"Inf\n"; else if((int)fabs(i)==(int)fabs(j)) cout<<"1\n"; else cout<<"2\n"; } void play(){ char start[2]; char end[2]; char a,b,c,d; cin>>start; cin>>end; a=start[0]; b=start[1]; c=end[0]; d=end[1]; if(a>'g'||a<'a'||c>'g'||c<'a'||b>8||b<1||d>8||d<1) return; if(a==c&&b==d){ cout<<"0 0 0 0\n"; return; } wang(a,b,c,d); hou(a,b,c,d); che(a,b,c,d); xiang(a,b,c,d); } void main(){ int num,p=1; cin>>num; if(num<0||num>20) return; while(p<=num) { play(); p++;} } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator