[백준 5565, Cpp] 영수증

나무에물주기·2022년 10월 21일
0

Coding Test

목록 보기
49/77
// 백준  5565 영수증

#include <iostream>
using namespace std;

int main()
{
	// 책 10권의 총 가격 입력
	int TotalPrice; 
	cin >> TotalPrice;

	// 1권당 가격을 입력받을 array와, 개별 책의 가격을 더해줄 변수 result 생성
	int Price[9];
	int result = 0;

	// 9번을 반복하면서 개별책의 가격을 입력받고, result 변수에 더해줌
	for (int i = 0; i < 9; i++)
	{
		cin >> Price[i];
		result += Price[i];
	}

	// 10권의 총 가격에서(TotalPrice) 9권의 가격을 더해준(result)를 빼서 출력 
	cout << TotalPrice - result << endl;

	return 0;
}
profile
개인 공부를 정리함니다

0개의 댓글