From e06e40af3b1907b63d8e0bc9094c236424d2d0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Thu, 18 Oct 2018 15:05:01 +0200 Subject: [PATCH] Implement verbose option. --- src/args.h | 20 ++++++++++++++++++++ src/main.c | 9 +++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/args.h diff --git a/src/args.h b/src/args.h new file mode 100644 index 0000000..d7d8cdc --- /dev/null +++ b/src/args.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2018 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + diff --git a/src/main.c b/src/main.c index 39744d8..29e954d 100644 --- a/src/main.c +++ b/src/main.c @@ -45,6 +45,8 @@ int main(int argc, char *argv[]) { mpz_set_ui(tmp, 2); llist_add(&prime_list, tmp); mpz_clear(tmp); + if(args.verbose) + puts("2"); } mpz_t aux; @@ -64,7 +66,14 @@ int main(int argc, char *argv[]) { item = item->next; } if(is_prime) + { llist_add(&prime_list, aux); + if(args.verbose) + { + mpz_out_str(stdout, 10, aux); + printf("\n"); + } + } mpz_add_ui(aux, aux, 2); }