topic
Title link
Problem-solving ideas
- C++ uses fixed and setprecision in the iomanip header file to control the number of decimal places
- Java uses to control the number of decimal places
- Python uses print and % to control the number of decimal places (format is also OK)
Code
#include <iostream>
#include <iomanip>
using namespace std;
int main(void)
{
ios::sync_with_stdio(false);
(0);
double n;
cin>>n;
cout<<fixed<<setprecision(3)<<n;
return 0;
}
import ;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner();
double n=();
("%.3f",n);
}
}
n=float(input())
print('%.3f'%n)
Algorithm and complexity
- Algorithm: None.
- Time complexity:\(\mathcal{O}(1)\) 。
- Space complexity:\(\mathcal{O}(1)\) 。
This is the solution to the Niuke input and output questions. Everyone is welcome to read the Niuke question bank. This is the solution to the Niuke input and output questions. Everyone is welcome to read the Niuke question bank. This is the solution to the Niuke input and output questions. Everyone is welcome to read the Niuke question bank. This is the solution to the Niuke input and output questions. Everyone is welcome to read the Niuke question bank. This is the solution to the Niuke input and output questions. Everyone is welcome to read the Niuke question bank.