OpenJudge 07:Output floating point number

Description

Read a dual - precision floating point number, according to the output format "%f", "%f" retains 5 digits, "%E" and "%G" output this integer, each time it is output alone.

Input

A dual - precision floating point number.

OUTPUT

There are four lines of output:
The first line is the dual - precision floating point number out of "%f";
The second line is to keep the dual - precision floating point of the 5 - digit decimal output according to "%F";
The third line is the dual - precision floating point number output by "%E";
The fourth row is the dual - precision floating point number output by "%g".

Input Sample

`12.3456789

OUTPUT SAMPLE

12.345679
12.34568
1.234568e+001
12.3457

source

Exercise (2.5)

idea

Format output with Printf.

Answer

CPP

include

include

using namespace std;
int Main ()
{{
double a;
cin >> a;
Printf ("%f \ n", a);
Printf ("%1.5F \ n", a);
Printf ("%e \ n", a);
Printf ("%g \ n", a);
Return 0;
}

Result

Used Memory: 200KB
Run time: 12ms
Language: G ++
Submit time: 2019-03-24 09:18:27

[http://noi.openjudge.cn/ch0101/07/.

OpenJudge 07:Output floating point number

https://blog.tsinbei.com/en/archives/199/

Author
Hsukqi Lee
Posted on

2022-02-20

Edited on

2022-08-04

Licensed under

CC BY-NC-ND 4.0

# Programing  Cpp  OpenJudge  NOI  NOIP

Comments

Name
Mail
Site
None yet