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:疯了!!!!!!!!!结果都对,就是不AC

Posted by wzf123 at 2006-07-23 17:07:34 on Problem 2562
In Reply To:疯了!!!!!!!!!结果都对,就是不AV Posted by:wzf123 at 2006-07-23 17:07:18
#include <stdio.h>

int oper(int n,int s[])
{
   int i=-1;
  
  while(n)
  {
	  
  s[++i]=n%10;
  n=n/10;
  }
  return i;
}
int main()
{
  int oper(int n,int s[]);
 long int n;
  long int m;
  int a[20]={0},b[20]={0},i,j,k,z,time,leap=0;

  while(0!=scanf("%u%u",&n,&m))
  {

	  if(n==0&&m==0)break;
    i=oper(n,a);
	j=oper(m,b);
	
       if(i>j)z=j;
	   else z=i;
     
    for (k=0,time=0,leap=0;k<=z+1;k++) 
	{   
		
		if(a[k]+b[k]+leap>=10)
		{	time++;
		  leap=1;
        }
		else leap=0;
    }


   if(time==0)
	  printf("No carry operation.\n");
    if(time==1)
	  printf("1 carry operation.\n");
    if(time>1)
     printf("%d carry operations.\n",time);
  }
   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