본문 바로가기
c++/백준

[백준] 1008번 A/B(c++)

by ilp 2023. 12. 23.
반응형

https://www.acmicpc.net/problem/1008

 

1008번: A/B

두 정수 A와 B를 입력받은 다음, A/B를 출력하는 프로그램을 작성하시오.

www.acmicpc.net



#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double a,b;
    cin>>a>>b;
    cout.precision(9);
    cout<<fixed;
    cout<<a/b;
    return 0;
}

 

1. 변수

  • 'a': 입력받는 첫번째 실수이다.
  • 'b': 입력받는 두번째 실수이다.

2. 입력

  •  'a' 'b'에 입력받는다.
  • 'double'형 실수를 입력 받는다.

3. 출력

  • 소수점 아래 9자리까지 출력한다.
  • 'a/b' 출력한다.

 

 

참고

https://iloveprogramming.tistory.com/116

 

[c++] 소수점 자릿수 조절하기

1. 'std::fixed' 와 'std::setprecision' 소수점 아래의 자리수를 정확하게 지정할 수 있다. '' 해더 파일에 있다. double num = 3.14159265; cout

iloveprogramming.tistory.com



반응형

'c++ > 백준' 카테고리의 다른 글

[백준] 2439번 별 찍기 - 2(c++)  (0) 2023.12.23
[백준] 2438번 별 찍기 - 1(c++)  (2) 2023.12.23
[백준] 9086번 문자열(c++)  (0) 2023.12.23
[백준] 1001번 A-B(c++)  (0) 2023.12.23
[백준] 1000번 A+B(c++)  (0) 2023.12.23