#include <iostream>
#include <iomanip>
using namespace std;
int main(){
long double a,b;
cin >> a >> b;
cout << setprecision(15) << a / b << endl;
return 0;
}
setprecision()에 인자를 통해 몇 번째 자리수까지 출력할지를 결정함.
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
long double a,b;
cin >> a >> b;
cout << fixed << setprecision(numeric_limits<long double>::max_digits10) << a/b << endl;
return 0;
}
위와 같은 방법으로 상수 max_digits10 = 21 만큼의 소수점 자릿수를 출력 가능함.
'algorithm(c++)' 카테고리의 다른 글
| 달팽이는 올라가고 싶다 (0) | 2023.04.24 |
|---|---|
| 물통 옮기기 (0) | 2023.04.21 |
| 분수 찾기 알고리즘 아이디어 (0) | 2023.04.12 |
| 그룹단어 체커 아이디어 (0) | 2023.03.31 |
| c++ vector reverse, 반복자와 포인터 차이, 배열로 점수 쌓기, 공백포함 문자열 입력 (0) | 2023.03.22 |