Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:为什麽打一行却输出上一行得值?困惑~~~~~~~~

Posted by sxxzpxy at 2004-12-14 21:05:22 on Problem 1657
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator