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

帮帮偶啊!老是wa。。。。呜呜。。。跪求高人看下。。。数据都过了

Posted by xxnan at 2010-12-08 19:44:58 on Problem 2845 and last updated at 2010-12-08 20:25:19
#include<stdio.h>
#include<math.h>
#define N 1000
main()
{
  int n,i,j,l1,l2,k,c[N],x;
  double  s1,s2,t;
  char a[N],b[N];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
	  scanf("%s%s",a,b);s1=0;s2=0;
	  l1=strlen(a);l2=strlen(b);
	  for(j=0;j<l1;j++)
	    {
		  s1=s1+(a[j]-48)*pow(2,l1-1-j);
		}
      for(x=0;x<l2;x++)
	    {
		  s2=s2+(b[x]-48)*pow(2,l2-1-x);
		}
		t=s1+s2;k=0;
		if(t==0)
		{
		   printf("%d ",i+1);
		   printf("0\n");
		}
		else
		{
	    	while(t!=0)
		     {
		        c[k++]=(int)t%2;
		        t=(int)t/2;
		     
		     }	
		     printf("%d ",i+1);
		     for(j=k-1;j>=0;j--)
		       {
		         printf("%d",c[j]);
			
		       }
		   printf("\n");
		}
	}
return 0;
}

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