正在加载图片...
Problem 1a) int main() int i; double *basic,pascal[3]: for (i=0;i<3;i++) pascal[i]=6/(i+1); Language(&basic,pascal[2],pascal); //Draw a diagram indicating the contents of memory at this point. } void Language(double **logo,int c,double java[]) *logo new double [c]; java++; *0ava+1)=4: for (int i=0;i<c;i++) javali]javali]/2: (*1ogo[1]=7; *10g0=3.2: } Problem 1b) #define ARRAY SIZE 10 int main( { int array[ARRAY SIZE]: int *ptr1,*ptr2,temp,i; for0=0:i<10:it+) { array[i]=i*i; /Draw a diagram indicating the contents of memory at this point. ptr1 array +ARRAY SIZE/2: ptr2 ptr1++; /Draw a diagram indicating the contents of memory at this point. while(ptr2>=array &ptr1 array +ARRAY_SIZE) temp =*ptr2; *ptr1 =*ptr2--; *ptr1++=temp; } /Draw a diagram indicating the contents of memory at this point. *(--ptr1)=ARRAY_SIZE; for(i=0;i<ARRAY SIZE;i+=2) { *(ptr2+i-1)=i, /Draw a diagram indicating the contents of memory at this point.Problem 1a) int main() { int i; double *basic, pascal[3]; for (i = 0; i < 3; i++) { pascal[i] = 6 / (i + 1); } Language(&basic, pascal[2], pascal); //Draw a diagram indicating the contents of memory at this point. } void Language(double **logo, int c, double java[]) { *logo = new double [c]; java++; *(java + 1) = 4; for (int i = 0; i < c; i++) { java[i] = java[i] / 2; } (*logo)[1] = 7; **logo = 3.2; } Problem 1b) #define ARRAY_SIZE 10 int main() { int array[ARRAY_SIZE]; int *ptr1, *ptr2, temp, i; for (i = 0; i < 10; i++) { array[i] = i * i; } // Draw a diagram indicating the contents of memory at this point. ptr1 = array + ARRAY_SIZE / 2; ptr2 = ptr1++; // Draw a diagram indicating the contents of memory at this point. while (ptr2 >= array && ptr1 < array + ARRAY_SIZE) { temp = *ptr2; *ptr1 = *ptr2--; *ptr1++ = temp; } // Draw a diagram indicating the contents of memory at this point. *(--ptr1) = ARRAY_SIZE; for (i = 0; i < ARRAY_SIZE; i += 2) { *(ptr2 + i - 1) = i; } // Draw a diagram indicating the contents of memory at this point. }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有