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:90405102 at 2004-12-14 20:19:45 > #include<stdio.h> > #include<math.h> > int wang(int a,int b,int c,int d){ > if(abs(a-c)<abs(b-d))return (abs(b-d)); > else return (abs(a-c)); > } > int hou(int a,int b,int c,int d){ > if(abs(a-c)==abs(b-d)||a-c==0||b-d==0) return (1); > else return(2); > } > int che(int a,int b,int c,int d){ > if(a-c==0||b-d==0) return(1); > else return(2); > } > > int xiang(int a,int b,int c,int d){ > if((a+b+c+d)%2==1) return(0); > else if(abs(a-c)==abs(b-d)) return(1); > else return(2); > } > > > void main(){ > > > > > int n,i,b,e,x,y; > char a,c,d; > scanf("%d\n",&n); > for(i=1;i<=n;i++){ > scanf("%c%d%c%c%d\n",&a,&b,&c,&d,&e); > x=a-'a'+1;y=d-'a'+1; > printf("%d ",wang(x,b,y,e)); > printf("%d ",hou(x,b,y,e)); > printf("%d ",che(x,b,y,e)); > if(xiang(x,b,y,e)==0) printf("Inf\n"); > else printf("%d\n",xiang(x,b,y,e)); > } > } 把scanf中的内容去掉“\n”试试 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator