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()