From 5b01488ce73be6b5ffd40e72dda59dba5a354915 Mon Sep 17 00:00:00 2001 From: zeekling Date: Tue, 6 Dec 2022 22:40:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=89=E6=AF=94=E6=95=B0=E5=88=97=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/dengbishulie.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 base/dengbishulie.c diff --git a/base/dengbishulie.c b/base/dengbishulie.c new file mode 100644 index 0000000..bf6fa8b --- /dev/null +++ b/base/dengbishulie.c @@ -0,0 +1,25 @@ + +#include +#include + +int main(int argc, char *argv[]) { + + if(argc != 4) { + return -1; + } + int a1 = atoi(argv[1]); + int q = atoi(argv[2]); + int n = atoi(argv[3]); + printf("a1=%d, n=%d,q=%d\n", a1, n, q); + int i=0; + int sum = 0; + int a = a1; + while (i < n) { + sum += a; + a *= q; + i++; + } + printf("sum=%d\n", sum); + return 0; +} +