Problem solving Report of 2765 octal decimal points in Bailian

Source: Internet
Author: User

Link: http://poj.grids.cn/practice/2765/

Question:

Total time limit:
1000 ms
Memory limit:
65536kB
Description
Decimal decimal places can be exactly expressed. For example, 0.75 in octal equals 0.963125 in decimal format (7/8 + 5/64 ). All octal decimal places with n digits after the decimal point can be expressed as decimal places with no more than 3n digits after the decimal point.

Your task is to write a program to convert the octal decimal places (0, 1) into decimal places.
Input
The input includes several octal decimal places, each occupying a row. Each decimal point is in the form of 0. d1d2d3... dk. Here di is the eight decimal number 0... 7, and 0 <k <15 is known.
Output
For each input octal decimal point, enter a row in the form below

0. d1d2d3... dk [8] = 0. D1D2D3... Dm [10]

Here, the left side is the input decimal place, and the right side is an equal decimal place. The output decimal point cannot end with 0, that is, Dm is not equal to 0.
Sample Input
0.750.00010.01234567
Sample output
0.75 [8] = 0.953125 [10]0.0001 [8] = 0.000244140625 [10]0.01234567 [8] = 0.020408093929290771484375 [10]
Prompt
If you use a string to read decimal digits, you can abort the input as follows:

Char octal [100];
While (cin> octal ){
...
}

Code:

 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring>                    octal[     (cin >>           sum =           step =           length =         ( i = ; i < length; i++              sum += (octal[i] - ) *             step = step *                    printf(             }

 

Ideas:

1. Solve the Accuracy Problem with % 0.45g

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.