正在加载图片...
Function:ResetArray Usage:ResetArray(array,n); 米 This function sets the first n elements of array to the first n integers starting with 1.Thus,calling *ResetArray(array,4)would set the first four elements of array to 1,2,3,and 4,respectively. static void ResetArray(int array[].int n) int i; for (i=0;i<n;i++) array[i]=i+1; } 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++) if1>0) cout<<",": cout <array[i]; cout <<"HIn"; } The functions on this page of the exam do exactly what their comments say they do.In particular,the Checkpoint function displays 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:{1,2,3,4,5,6,7,8} Checkpoint 1: Checkpoint 2: Checkpoint 3: Checkpoint 4:/* * Function: ResetArray * Usage: ResetArray(array, n); * --------------------------------- * This function sets the first n elements of array to the * first n integers starting with 1. Thus, calling * ResetArray(array, 4) would set the first four elements * of array to 1, 2, 3, and 4, respectively. */ static void ResetArray(int array[], int n) { int i; for (i = 0; i < n; i++) array[i] = i + 1; } /* * 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 functions on this page of the exam do exactly what their comments say they do. In particular, the Checkpoint function displays 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: { 1, 2, 3, 4, 5, 6, 7, 8 } Checkpoint 1: Checkpoint 2: Checkpoint 3: Checkpoint 4:
<<向上翻页
©2008-现在 cucdc.com 高等教育资讯网 版权所有