| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
迷茫,将temp改成字符型指针本地数据过了,提交不过#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator