mirror of
https://github.com/nolongeractivemp3/shipthatcode-c.git
synced 2026-11-24 10:45:12 +01:00
lesson 7 i read the thingy wrong
This commit is contained in:
1 parent
8fc7170ccd
commit
6d96a16d20
2 files changed
+16
-17
No files matched your search
@@ -0,0 +1,8 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"label": "Debug C",
|
||||||
|
"program": "$ZED_WORKTREE_ROOT/main",
|
||||||
|
"request": "launch",
|
||||||
|
"adapter": "CodeLLDB",
|
||||||
|
},
|
||||||
|
]
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user