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>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
int resultof3 = n%3;
|
||||
int resultof5 = n%5;
|
||||
if (!resultof5 && !resultof3) {
|
||||
printf("FizzBuzz");
|
||||
} else if (!resultof3) {
|
||||
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 */
|
||||
long long result = 0;
|
||||
long imat = 1;
|
||||
while (!(imat>n)) {
|
||||
result = result +imat;
|
||||
imat = imat+2;
|
||||
|
||||
}
|
||||
|
||||
printf("%lld", result);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user