From dae819bf039386e9c474f7b96a5b5d5f263bf421 Mon Sep 17 00:00:00 2001 From: smallkun Date: Mon, 31 Mar 2025 20:03:24 +0800 Subject: [PATCH] Auto commit --- 万维调考试题源码/5-1.c | 14 +++++++++++++- 万维调考试题源码/5-2.c | 12 +++++++++++- 万维调考试题源码/6-1.c | 7 ++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/万维调考试题源码/5-1.c b/万维调考试题源码/5-1.c index 7423d48..ad9faae 100644 --- a/万维调考试题源码/5-1.c +++ b/万维调考试题源码/5-1.c @@ -33,7 +33,19 @@ void removeDuplicates(char *str) if (len <= 1) return; /**********Program**********/ - + for(i=0;i0;i++,decimal/=2){ + binary[i] = decimal%2+48; + } + binary[i] = '\0'; + i--; + for(;i>len;i--){ + remainder = binary[len]; + binary[len] = binary[i]; + binary[i] = remainder; + len++; + } /********** End **********/ printf("%s\n", binary); } diff --git a/万维调考试题源码/6-1.c b/万维调考试题源码/6-1.c index 6080637..76e1c6f 100644 --- a/万维调考试题源码/6-1.c +++ b/万维调考试题源码/6-1.c @@ -17,7 +17,12 @@ int countPeaches(int lastDay) int peaches = 1; int day; /**********Program**********/ - + day = lastDay; + while(day>1){ + peaches = (peaches+1)*2; + day--; + } + return peaches; /********** End **********/ } int main()