diff options
author | David Timber <dxdt@dev.snart.me> | 2024-11-12 05:57:44 +0100 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2024-11-12 05:57:44 +0100 |
commit | 5fc6f750a207a9918c33f050409feae9f3dd3166 (patch) | |
tree | cf2c18b9ebb5c7c3cfefb1271696f97eda20eaef /qna/아픈뜸부기_a.c | |
parent | be3b15d64e9f6b8c2489b296c7f4b63487aa5564 (diff) |
Dump some files from personal directory
Diffstat (limited to 'qna/아픈뜸부기_a.c')
-rw-r--r-- | qna/아픈뜸부기_a.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/qna/아픈뜸부기_a.c b/qna/아픈뜸부기_a.c new file mode 100644 index 0000000..4022b8d --- /dev/null +++ b/qna/아픈뜸부기_a.c @@ -0,0 +1,34 @@ +#define _CRT_SECURE_NO_WARNING // https://blog.hcmc.studio/73 +#include <stdio.h> + +int main (void) { + int n, num; + int sum = 0; + int a, b, c, d; + + printf("4자리 정수를 입력하시오: "); + scanf("%d", &n); + num = n; + printf("\n"); + + a = n % 1000 % 100 % 10; + printf("\tn = %4d --> 일의 자리값 --> %d \n", n, a); + n = n % 1000; + + b = n / 10 % 10; + printf("\tn = %4d --> 십의 자리값 --> %d \n", n, b); + n = n / 100; + + c = n % 100 % 10; + printf("\tn = %4d --> 백의 자리값 --> %d \n", n, c); + n = n % 10; + + d = n % 10; + printf("\tn = %4d --> 천의 자리값 --> %d \n", n, d); + n = n % 10; + + sum = d + c + b + a; + printf("n = %4d --> %d + %d + %d + %d = %d \n", num, a, b, c, d, sum); + + return 0; +} |