diff --git a/万维调考试题源码/10-1.c b/万维调考试题源码/10-1.c index 4b2584c..79df517 100644 --- a/万维调考试题源码/10-1.c +++ b/万维调考试题源码/10-1.c @@ -21,7 +21,16 @@ void fun(int *w, int p, int n) { int temp[p + 1]; /**********Program**********/ - + int i,k=0; + for(i=0;i 1){ + boughtBottles-=2; + boughtBottles++; + totalBottlesDrank++; + } + return totalBottlesDrank; /********** End **********/ } int main() diff --git a/万维调考试题源码/7-1.c b/万维调考试题源码/7-1.c index 591f101..f022101 100644 --- a/万维调考试题源码/7-1.c +++ b/万维调考试题源码/7-1.c @@ -18,7 +18,24 @@ void fun(int *a, int n) int second_max_index = 0; int i; /**********Program**********/ - + for(i=1;ia[max_index]){ + max_index = i; + } + } + i=a[0]; + a[0]=a[max_index]; + a[max_index]=i; + second_max_index = 1; + for(i=1;ia[second_max_index]){ + second_max_index = i; + } + } + i=a[1]; + a[1]=a[second_max_index]; + a[second_max_index]=i; + /********** End **********/ } int main() diff --git a/万维调考试题源码/7-2.c b/万维调考试题源码/7-2.c index 1907a3e..4f33fcd 100644 --- a/万维调考试题源码/7-2.c +++ b/万维调考试题源码/7-2.c @@ -39,7 +39,35 @@ int computeSymmetricDifference(int A[], int sizeA, int B[], int sizeB, int C[]) { int i = 0, j = 0, k = 0; /**********Program**********/ - + while(i='a'&&*p<='z'){ + *p=((*p+1)<'z'?(*p+1):'a'); + } + if(*p>='A'&&*p<='Z'){ + *p=((*p+1)<'Z'?(*p+1):'A'); + } + p++; + } /********** End **********/ } int main() diff --git a/万维调考试题源码/8-2.c b/万维调考试题源码/8-2.c index 09087d6..c5ce2f6 100644 --- a/万维调考试题源码/8-2.c +++ b/万维调考试题源码/8-2.c @@ -12,7 +12,15 @@ int mySqrt(int x) { /**********Program**********/ - + int i; + for(i=1;;i++){ + if(i*i==x){ + return i; + } + if(i*i>x){ + return i-1; + } + } /********** End **********/ } int main() diff --git a/万维调考试题源码/9-1.c b/万维调考试题源码/9-1.c index e8a2d70..dbe6643 100644 --- a/万维调考试题源码/9-1.c +++ b/万维调考试题源码/9-1.c @@ -21,7 +21,15 @@ Program-End ֮ bool hasDuplicates(int arr[], int size) { /**********Program**********/ - + int i,j; + for(i=0;i