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

最后输入0时又有0的输出

Posted by 320109 at 2008-10-03 15:22:03 on Problem 1565
In Reply To:测试都过了,但是wa!!!! Posted by:kuangwenkui at 2007-06-16 19:40:11
最后输入0时又有0的输出
改一下就好了
#include<stdio.h>
#include<string.h>
#include<math.h>
main()
{
    char a[100];
    int i,j,len;
    int sum;
    scanf("%s",a);
    for(i=0;strcmp(a,"0")!=0;i++)
     {

         sum=0;
         len=strlen(a);
         for(j=0;j<len;j++)
	      {
	          sum = sum + (a[j]-'0')*((int)pow(2,(double)(len - j)) - 1 );
        }
      printf("%d\n",sum);
      scanf("%s",a);
     }
}

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