add c and cpp
This commit is contained in:
parent
d9a0aa3b61
commit
1f5b67dd15
3 changed files with 35 additions and 0 deletions
|
@ -0,0 +1,4 @@
|
|||
# Collection of FizzBuzz Programs
|
||||
|
||||
This repository contains various FizzBuzz implementations in various programming
|
||||
languages.
|
15
src/fb.c
Normal file
15
src/fb.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
int main(int argc, char *argv[]) {
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
if (i % 15 == 0) {
|
||||
puts("FizzBuzz");
|
||||
} else if (i % 3 == 0) {
|
||||
puts("Fizz");
|
||||
} else if (i % 5 == 0) {
|
||||
puts("Buzz");
|
||||
} else {
|
||||
printf("%d\n", i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
16
src/fb.cpp
Normal file
16
src/fb.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
int main() {
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
if (i % 15 == 0) {
|
||||
cout << "FizzBuzz" << endl;
|
||||
} else if (i % 3 == 0) {
|
||||
cout << "Fizz" << endl;
|
||||
} else if (i % 5 == 0) {
|
||||
cout << "Buzz" << endl;
|
||||
} else {
|
||||
cout << i << endl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue