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 |
Re:高手们帮我看看到底那儿错了,谢谢:)In Reply To:高手们帮我看看到底那儿错了,谢谢:) Posted by:huhu at 2006-02-23 15:49:08 > #include<iostream.h> > void main(){ > int x,a,b,A1,A2,wang,hou,che; > char c,d,xiang; > cin>>x; > for(int i=0;i<x;i++){ > cin>>c>>a>>d>>b; > if((a>8||a<0)||(b>8||b<0)||(c>'h')||(d>'h'))break; > if(a==b&&c==d) > cout<<"0 0 0 0"<<endl; > if (a>b||a==b) A1=a-b; > else A1=b-a; > if(c>d||c==d) A2=c-d; > else A2=d-c; > if (A1>A2||A1==A2) wang=A1; > else int wang=A2; > if(A1==0||A2==0||A1==A2) hou=1; > else hou=2; > if(A1==0||A2==0) che=1; > else che=2; > if((A1-A2)%2==0){ > if(A1-A2==0)xiang='1'; > else xiang='2'; > cout<<wang<<" "<<hou<<" "<<che<<" "<<xiang<<endl; > } > else cout<<wang<<" "<<hou<<" "<<che<<" Inf"<<endl; > } > } > > > 感觉没错啊.... 我是这样的算法,AC了.不过我感觉你的变量定义得有些乱...最好用字符串做输入,用整数做部数... Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator