[C++] baekjoon 5565, 10952

oat·2024년 3월 2일

everydayBOJ

목록 보기
29/51

Day 29

5565

문제

code

#include<iostream>

using namespace std;

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

    for (int i = 0; i < 9; i++) {
        int n;
        cin >> n;
        totalCharge -= n;
    }

    cout << totalCharge;

    return 0;
}

풀이 과정

전체 금액을 입력받고, for문을 통해 9권의 책 가격을 받는 동시에 전체 금액에서 차감하여 나머지 한 책의 가격을 출력하도록 하였다


10952

문제

code

#include<iostream>

using namespace std;

int main() {
    int total;
    int A, B;
    cin >> A >> B;
    while (A != 0 || B != 0) {
        cout << A + B << endl;
        cin >> A >> B;
    }

    return 0;
}

풀이 과정

0 0이 입력될 때까지 덧셈을 반복하기 위해 while문을 사용하였다

0개의 댓글