말랑한 하루

[SW Expert Academy] 1986 지그재그 숫자 [C++] 본문

문제풀이/SWexpert Academy

[SW Expert Academy] 1986 지그재그 숫자 [C++]

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

[ 핵심풀이 ]

[ 핵심소스 ]

[ C++ ]

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

using namespace std;

#define endl "\n"
#define MAX 5

int main() {
    int tc;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        int temp;
        cin >> temp;
        if (temp % 2 == 0)
            cout << "#" << t << " " << (temp / 2) * -1 << endl;
        else 
            cout << "#" << t << " " << (temp / 2) * -1 + temp << endl;
	}
}
반응형
Comments