正在加载图片...
/*Main program*/ main( { int i,*p; Checkpoint(0,a1,5); Bizarre(a1,a2,5); Checkpoint(1,a1,5); p=Weird(Weird(a2,2),4); Checkpoint(2,a2,5); static void Bizarre(int *p1,int *p2,int n) int*p3,*array; array p3=new int[n]; while(n-->0) *p3++=p1[*p2+小 while(p3--I=array) p1[p3-array]=*p3; } static int *Weird(int array[],int n) int *p,i; p=array; for (i=1;i<n;i++) if (*p array[i])p=array i; (p- return(p); Function:Checkpoint Usage:Checkpoint(ckpt,array,n); This function is used to display checkpoints in the program The output consists of the checkpoint number followed by the contents of the first n elements of array. * static void Checkpoint(int ckpt,int array,int n) int i; cout <<"Checkpoint"<<ckpt<<":{"; for (i=0;i<n;i++) r f(i>0) cout<<"," cout <array[i]; cout <<"HIn"; The Checkpoint function does exactly what its comments say it does:it display the contents of an array preceded by a checkpoint number.Thus,to answer this problem,all you have to do is show the output at each of the calls to Checkpoint.The results of the first call are filled in as an example. Checkpoint0:{100,200,300,400,500} Checkpoint 1: Checkpoint 2:/* Main program */ main() { int i, *p; Checkpoint(0, a1, 5); Bizarre(a1, a2, 5); Checkpoint(1, a1, 5); p = Weird(Weird(a2, 2), 4); Checkpoint(2, a2, 5); } static void Bizarre(int *p1, int *p2, int n) { int *p3, *array; array = p3 = new int[n]; while (n-- > 0) *p3++ = p1[*p2++]; while (p3-- != array) p1[p3 - array] = *p3; } static int *Weird(int array[], int n) { int *p, i; p = array; for (i = 1; i < n; i++) if (*p < array[i]) p = array + i; (*p)--; return (p); } /* * Function: Checkpoint * Usage: Checkpoint(ckpt, array, n); * ---------------------------------- * This function is used to display checkpoints in the program * The output consists of the checkpoint number followed by * the contents of the first n elements of array. */ static void Checkpoint(int ckpt, int array[], int n) { int i; cout << "Checkpoint " << ckpt << ": { " ; for (i = 0; i < n; i++) { if (i > 0) cout << ", "; cout << array[i]; } cout << " }\n"; } The Checkpoint function does exactly what its comments say it does: it display the contents of an array preceded by a checkpoint number. Thus, to answer this problem, all you have to do is show the output at each of the calls to Checkpoint. The results of the first call are filled in as an example. Checkpoint 0: { 100, 200, 300, 400, 500 } Checkpoint 1: Checkpoint 2:
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有