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 TheBeet at 2006-08-08 09:38:29 on Problem 1663
In Reply To:哪位高人指点一下啊... Posted by:snailly18 at 2006-07-21 21:12:32
> #include <stdio.h>
> #include<stdlib.h>
> void main()
> {
> 	int n;
> 	int *x,*y;
> 	int i=0;
> 	scanf("%d",&n);
> 	x=(int *)malloc(n*sizeof(int));
> 	y=(int *)malloc(n*sizeof(int));
> 	for(i=0;i<n;i++)
> 	{
> 		fflush(stdin);
> 		scanf("%d %d",&x[i],&y[i]);
> 	}
> 	for(i=0;i<n;i++)
> 	{
>         if(x[i]!=y[i]&&x[i]!=y[i]+2)
> 			printf("No Number\n");
> 		if(x[i]==y[i])
> 		{
> 			if(x[i]%2==0)
> 				printf("%d\n",(x[i]/2)*4);
> 			else if(x[i]%2==1)
> 	        		   printf("%d\n",(x[i]/2)*4+1);
> 		}
> 	    else if(x[i]==y[i]+2)
> 		{
> 			if(y[i]%2==0)
> 				printf("%d\n",(y[i]/2)*4+2);
> 			else if(y[i]%2==1)
> 		    		printf("%d\n",(y[i]/2)*4+3);
> 		}
> 
> 	}
> }
> 为什么wa啊?给祭祖错误数据也好啊.......
> 谢谢谢谢.........

代码太长 看晕了。。。
给您我的代码:
scanf("%d%d",&n,&m);
if ((n==m)||(n-2==m))
	printf("%d\n",n+m-(n%2));
else
	printf("No Number\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