Created
January 15, 2018 13:42
-
-
Save tamago324/76eb81b32368e5e233af24a9ef0f57c1 to your computer and use it in GitHub Desktop.
FIzz BuzzをC言語で実装。コマンドライン引数で入力された値に対してFizzBuzzする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char *argv[]){ | |
if (argc < 2) { | |
printf("コマンドライン引数を指定してください\n"); | |
exit(1); | |
} | |
// Fizz Buzz | |
for (int i = 1; i < argc; i++) { | |
if (i % 15 == 0) { | |
printf("Fizz Buzz\n"); | |
} else if (i % 5 == 0) { | |
printf("Buzz\n"); | |
} else if (i % 3 == 0) { | |
printf("Fizz\n"); | |
} else { | |
printf("%s\n", argv[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment