※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 26575번 문제인 Pups이다.
문제는 아래 링크를 확인하자.

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

 

26575번: Pups

Congratulations, you adopted some little puppies! Now you just need to go grab food for them at the store. Your vet tells you how many pounds of food each pup will eat before your next trip to the store, so you just need to calculate the total amount of fo

www.acmicpc.net

각 테스트케이스마다, 각 줄에 주어지는 세 실수의 곱을 출력해 문제를 해결하자.

 

예제에 주어진 것과 같이 입력으로 주어지는 실수를 나타내는 문자열이 숫자가 아닌 소수점으로 시작하게끔 주어지더라도 cin을 통해 올바르게 입력받을 수 있으니 참고해 구현하자.

 

아래는 제출한 소스코드이다.

#include <iostream>
using namespace std;
typedef long double ld;

int T;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> T;

	cout << fixed;
	cout.precision(2);

	while (T--) {
		ld d, f, p; cin >> d >> f >> p;
		cout << '$' << d * f * p << '\n';
	}
}
728x90

'BOJ' 카테고리의 다른 글

[BOJ 5300 // C++] Fill the Rowboats!  (0) 2022.12.19
[BOJ 26500 // C++] Absolutely  (0) 2022.12.19
[BOJ 26530 // C++] Shipping  (0) 2022.12.19
[BOJ 26489 // C++] Gum Gum for Jay Jay  (0) 2022.12.18
[BOJ 2773 // C++] 바깥 삼각형의 중심  (0) 2022.12.18

+ Recent posts