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

迷茫,将temp改成字符型指针本地数据过了,提交不过

Posted by CYL1937 at 2012-11-18 20:15:57
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;
int main()
{
    int num;
    double j;
   char temp[40];

    while(scanf("%s",temp)!=EOF)
    {
        if(!strcmp(temp,"0"))
         break;
        num=0;
       int i=strlen(temp);
       for(int k=0;k<i;k++)
        {
            j=temp[k]-'0';  //将字符转换成实数
            num+=j*(pow(2,double(i-k))-1);
        }
      printf("%d\n",num);
    }
    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