lesson 7 i read the thingy wrong

This commit is contained in:
deck committed 2026-10-06 21:46:11 +02:00
1 parent 8fc7170ccd
commit 6d96a16d20
2 files changed
+16 -17

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
[
{
"label": "Debug C",
"program": "$ZED_WORKTREE_ROOT/main",
"request": "launch",
"adapter": "CodeLLDB",
},
]
+8 -17
View File
@@ -1,25 +1,16 @@
#include <stdio.h> #include <stdio.h>
int main(void) { int main(void) {
int n; int n;
scanf("%d", &n); scanf("%d", &n);
int resultof3 = n%3; long long result = 0;
int resultof5 = n%5; long imat = 1;
if (!resultof5 && !resultof3) { while (!(imat>n)) {
printf("FizzBuzz"); result = result +imat;
} else if (!resultof3) { imat = imat+2;
printf("Fizz");
} else if (!resultof5) {
printf("Buzz");
} else {
printf("%d", n);
}
/* TODO: print exactly one line:
multiple of 3 and 5 -> FizzBuzz
multiple of 3 only -> Fizz
multiple of 5 only -> Buzz
anything else -> the number itself */
}
printf("%lld", result);
return 0; return 0;
} }