SW ExpertAcademy/D2
1926. 간단한 369게임
Programmer.
2018. 12. 1. 16:11
1926. 간단한 369게임
풀이 방법
<코드>
#include <iostream> int check369(int number) { int retval{ 0 }; int value = number; while (value != 0) { int test = value % 10; if (test == 3 || test == 6 || test == 9) retval++; value /= 10; } return retval; } int main(int argc, char** argv) { std::ios::sync_with_stdio(false); std::cout.tie(nullptr); std::cin.tie(nullptr); int nValue{}; std::cin >> nValue; for (int i = 1; i <= nValue; i++) { int count{}; if ((count = check369(i)) > 0) for (int j = 0; j < count; j++) std::cout << "-"; else std::cout << i; std::cout << " "; } std::cout << "\n"; return 0; }