From 53b34d917fd3cf3d9d498cc671f37d452646d195 Mon Sep 17 00:00:00 2001 From: smallkun Date: Tue, 1 Apr 2025 18:56:19 +0800 Subject: [PATCH] Auto commit --- 万维调考试题源码/4-1.c | 8 ++++---- 万维调考试题源码/4-2.c | 12 ++++-------- 万维调考试题源码/error/3-A-2.c | 8 ++++---- 万维调考试题源码/error/4-1.c | 8 ++++++-- 万维调考试题源码/error/4-2.c | 8 ++++++-- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/万维调考试题源码/4-1.c b/万维调考试题源码/4-1.c index c2b1233..2110e44 100644 --- a/万维调考试题源码/4-1.c +++ b/万维调考试题源码/4-1.c @@ -20,11 +20,11 @@ int main() int money = 100; int year = 1; /**********Program**********/ - while(money > 0){ - money = money + money*0.04; - money -= 10; + do{ + money = money *(1+0.04); + money-=10; year++; - } + }while(money > 0); /********** End **********/ printf("%d ˻ϵǮᱻ", year); printf("\n"); diff --git a/万维调考试题源码/4-2.c b/万维调考试题源码/4-2.c index 10ae444..389fcf6 100644 --- a/万维调考试题源码/4-2.c +++ b/万维调考试题源码/4-2.c @@ -31,14 +31,10 @@ void sort(int *p, int n) { int i, j, temp; /**********Program**********/ - i = 0; - j = n-1; - while(i < j){ - temp = p[i]; - p[i] = p[j]; - p[j] = temp; - i++; - j--; + for(i=0,j=n-1;i 0); /********** End **********/ printf("%d ˻ϵǮᱻ", year); printf("\n"); return 0; -} \ No newline at end of file +} diff --git a/万维调考试题源码/error/4-2.c b/万维调考试题源码/error/4-2.c index 3485462..389fcf6 100644 --- a/万维调考试题源码/error/4-2.c +++ b/万维调考试题源码/error/4-2.c @@ -31,6 +31,10 @@ void sort(int *p, int n) { int i, j, temp; /**********Program**********/ - + for(i=0,j=n-1;i