[백준/C++] 10170 - 쿠폰

orangesnail·2025년 8월 16일

백준

목록 보기
143/169

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


c++에는 round() 함수 같은게 없다...
소수점 아래 n번째 자리까지 출력하고 싶다면 <iomanip>를 include 해준 다음에 cout << fixed << setprecision(n) << 변수 을 이용해 출력이 가능하다.

#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    int t;
    cin >> t;

    for (int i = 0; i < t; i++) {
        double price;
        cin >> price;

        price *= 0.8;
        cout << "$" << fixed << setprecision(2) << price << endl;
    }
    return 0;
}
profile
초보입니다. 피드백 환영합니다 😗

0개의 댓글