말랑한 하루

[SW Expert Academy] 1225 암호생성기 [C++] 본문

문제풀이/SWexpert Academy

[SW Expert Academy] 1225 암호생성기 [C++]

지수는말랑이 2021. 1. 20. 01:10
반응형

[ 핵심풀이 ]

 

[ 핵심소스 ]

 

[ C++ ]

#include <iostream>
#include <queue>
#pragma warning(disable:4996)

using namespace std;

#define endl "\n"
#define tap "\t"
int main() {
    int tc;
    while (cin >> tc) {
        queue <int> q;
        for (int i = 0; i < 8; i++) {
            int temp;
            cin >> temp;
            q.push(temp);
        }
        int index = 0;
        while (!q.empty()) {
            index == 5 ? index = 1 : index++;
            int out = q.front(); q.pop();
            int in = out - index;
            if (in <= 0) {
                q.push(0);
                break;
            }
            q.push(in);
        }
        int Size = q.size();
        cout << "#" << tc << " ";
        while (Size-- > 0) {
            cout << q.front() << " ";
            q.pop();
        }
        cout << endl;
    }
}
반응형
Comments