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:为什么我考虑了出发地和目的地一样的情况还是WA...泪!!In Reply To:Re:为什么我考虑了出发地和目的地一样的情况还是WA...泪!! Posted by:cpp00648027 at 2007-03-04 18:39:37 > #include<iostream> > #include<cmath> > using namespace std; > int main() > { > int max,count=0,mini,big; > int p1,p2,p3,p4; > int hori,upri;//hori是横坐标之差,upri是纵坐标之差 > char star[3],dest[3];//star是出发地,dest是目的地 > cin>>max; > > while(count < max) { > if( max>20 || max<0 ) > break; > cin>>star>>dest; > if( star[0]>'h' || star[0]<'a' || star[1]>'8' || star[1]<'1') > break; > hori = abs(star[0] - dest[0]); > upri = abs(star[1] - dest[1]); > if(hori > upri) { > mini = upri; > big = hori; > } > else { > mini = hori; > big = upri; > } > > if( hori==0 && upri==0 )//原地不动 > cout<<"0 0 0 0"<<endl; > else { > p1 = big;//王总在走直线 > > if( mini==0 || mini==big )//连线不斜,或倾斜45度 > p2 = 1; > else > p2 = 2; > > if( mini==0 )//连线不是斜的 > p3 = 1; > else > p3 = 2; > > if( mini==big )//倾斜45度 > p4 = 1; > else > p4 = -1;//无法到达的标记为-1 > > if(p4!=-1) > printf("%d %d %d %d\n",p1,p2,p3,p4); > else > printf("%d %d %d Inf\n",p1,p2,p3); > } > > count++; > } > return 0; > } > 改了一下. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator