1. 程式人生 > >noi 八進位制小數

noi 八進位制小數

 1 #include <cmath>
 2 #include <cstdio>
 3 #include <cstring>
 4 double n2=0;
 5 char n1[20];
 6 int main()
 7 {
 8     scanf("%s",n1);
 9     int nl=strlen(n1);
10     for(int i=2; i<nl; i++)
11         n2+=(n1[i]-'0')*1.0/pow(8,double(i-1));
12     printf("%s [8] = %.50g [10]",n1,n2);
13 return 0; 14 }

原題連結:http://www.noi.openjudge.cn/ch0113/03/