From 455c54bafed17c4ae3cb4164de20d19094b19275 Mon Sep 17 00:00:00 2001 From: Baruta Daniel Mihail <baruta.mihai@yahoo.com> Date: Wed, 17 Aug 2022 00:49:28 +0200 Subject: [PATCH] Add readme --- README.md | 9 +++++++++ src/main.c | 11 ----------- src/solution.c | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 README.md create mode 100644 src/solution.c diff --git a/README.md b/README.md new file mode 100644 index 0000000..3937d0e --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Perfect assignment + +Write a program that given a number as input argument prints the corespondig number of 1s on standard output. + +E.g: +```bash +$> ./binary 3 +1 1 1 +``` diff --git a/src/main.c b/src/main.c index ac5e990..4556184 100644 --- a/src/main.c +++ b/src/main.c @@ -3,16 +3,5 @@ int main(int argc, char **argv) { - if (argc != 2) { - fprintf(stderr, "Not enough arguments!\n"); - return 1; - } - - int number = atoi(argv[1]); - - for (int i = 0; i < number; i++) - printf("1 "); - - printf("\n"); return 0; } diff --git a/src/solution.c b/src/solution.c new file mode 100644 index 0000000..ac5e990 --- /dev/null +++ b/src/solution.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char **argv) +{ + if (argc != 2) { + fprintf(stderr, "Not enough arguments!\n"); + return 1; + } + + int number = atoi(argv[1]); + + for (int i = 0; i < number; i++) + printf("1 "); + + printf("\n"); + return 0; +} -- GitLab