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 duandong at 2008-03-10 20:42:04 on Problem 3508
#include<stdio.h> 
#include<string.h>
int main()
{
    char a[1000000],k=0;
    scanf("%s",a);
    while(strcmp(a,"0")!=0)
    {
	 					   k ++;
	 					   int i,t1 = 0,t2 = 0;
	 					   int result;
	 					   for( i = strlen(a)-1; i>=0 ; i --)
	 					   {
						   		             int temp = a[i] - '0';
						   		             int tr = temp - t1 - t2 ;
						   		             result = tr ;
									         if( result < 0 ) result += 10;
						   		             t1 = result;
						   		             if( tr < 0 ) t2 = 1 ; 
						   		             else t2 = 0 ;
										     a[i] = '0' + result;
  		                   }
  		                   if(a[0] == '0')
			               {
						   		   printf("%d. IMPOSSIBLE\n",k);
	                       }
	                       else printf("%d. %s\n",k,a);
                           scanf("%s",a);
    }
    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