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

我就是特例。。。。。

Posted by Ultramanhu at 2008-11-18 18:30:02 on Problem 2845
In Reply To:attention! Posted by:200609020331 at 2008-07-29 19:56:01
#include<stdio.h>
#include<string.h>
int a[100]={0};
int b[100]={0};
int c[100]={0};
char ch[200]={'\0'};
int n,m,i,j,k,m1,m2,m3;
int main()
{
   scanf("%d",&n);
   for(m=1;m<=n;m++)
   {
      scanf("%s",ch);
      m1=strlen(ch);
      for(i=m1;i>=1;i--)
      {
	 a[i]=ch[m1-i]-48;
      }
      scanf("%s",ch);
      m2=strlen(ch);
      for(i=m2;i>=1;i--)
      {
	 b[i]=ch[m2-i]-48;
      }
      if(m1>m2){m3=m1;}else{m3=m2;}
      m3++;k=0;
      for(i=1;i<=m3;i++)
      {
	 c[i]=a[i]+b[i]+k;
	 k=c[i]/2;
	 c[i]=c[i]%2;
      }
      printf("%d ",m);
      while((c[m3]==0)&&(m3>1)){m3--;}
      for(i=m3;i>=1;i--)
      {  printf("%d",c[i]);}
      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