From b5ef050bf88ba22ba2e8c24fcf84d2fe10e126f7 Mon Sep 17 00:00:00 2001 From: hanoong7 <108854591+hanoong7@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:34:40 +0900 Subject: [PATCH] =?UTF-8?q?2022/07/18=20=EC=9E=90=EB=A6=BF=EC=88=98=20?= =?UTF-8?q?=EB=8D=94=ED=95=98=EA=B8=B0=20=EB=AC=B8=EC=A0=9C=ED=92=80?= =?UTF-8?q?=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2022/07/18 자릿수 더하기 문제풀이입니다. --- c++ | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 c++ diff --git a/c++ b/c++ new file mode 100644 index 0000000..1400b74 --- /dev/null +++ b/c++ @@ -0,0 +1,20 @@ +#include +using namespace std; + +int solution(int N) { + int sum = 0; + int count = 100000000; + int temp = 0; + while (1) { + if (N >= count) { + temp = N / count; + sum += temp; + N -= temp * count; + } + count /= 10; + if (count < 1) { + break; + } + } + return sum; +}