forked from local-interloper/fizz-buzz
Init commit
This commit is contained in:
commit
95b560b955
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# g++ compiler output
|
||||
a.out
|
||||
16
index.js
Normal file
16
index.js
Normal file
@ -0,0 +1,16 @@
|
||||
for (let i = 1; i <= 100; i++) {
|
||||
let out = '';
|
||||
|
||||
if (i % 3 == 0) {
|
||||
out += 'Fizz';
|
||||
}
|
||||
if (i % 5 == 0) {
|
||||
out += 'Buzz';
|
||||
}
|
||||
|
||||
if (!out) {
|
||||
console.log(i);
|
||||
} else {
|
||||
console.log(out);
|
||||
}
|
||||
}
|
||||
25
main.c
Normal file
25
main.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
char out[30] = "";
|
||||
|
||||
if (i % 3 == 0) {
|
||||
strcat(out, "Fizz");
|
||||
}
|
||||
|
||||
if (i % 5 == 0) {
|
||||
strcat(out, "Buzz");
|
||||
}
|
||||
|
||||
if (strcmp(out, "") == 0) {
|
||||
printf("%d", i);
|
||||
} else {
|
||||
printf("%s", out);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
25
main.cpp
Normal file
25
main.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
string out = "";
|
||||
|
||||
if (i % 3 == 0) {
|
||||
out += "Fizz";
|
||||
}
|
||||
if (i % 5 == 0) {
|
||||
out += "Buzz";
|
||||
}
|
||||
|
||||
if (out == "") {
|
||||
cout << i << endl;
|
||||
} else {
|
||||
cout << out << endl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user