文件名称:homework
介绍说明--下载内容均来自于网络,请自行研究使用
将两个分别从小到大排列的有序数组a和b复制合并到第3个有序数组c中。m和 n分别是数组a和b的元素个数,结果c的元素个数为k。例如,a和b数组分别为{1,2, 2,3,8}和{3,4,7,8},则结果数组c的值是:{1,2,2,3,3,4,7,8,8)。算法是:将a、b两个数组看成两个队列,比较队首的两个元素,将较小者放入c队列尾部,如果队首的两个元素相等,则先选择a队列首部元素加入c队列尾部。循环执行以上过程,直到a或b队列之一为空,然后将另一个非空队列拷贝到c队列尾部。注意:不允许使用其它算法
(如排序算法)。试建立一个类Com,完成合并工作。-The two were in ascending order of an ordered array of a and b copied into the first three ordered array, c. m and n are each a and b is the number of array elements, the result is the number of elements c k. For example, a and b respectively, the array {1,2, 2,3,8} and {3,4,7,8}, the resulting values of the array c is: {1,2,2,3,3,4 , 7,8,8). Algorithm is: a, b two elements of two arrays as two queues, comparing the first team will put the smaller end of the queue c, if the team' s first two elements are equal, first select a queue header element Join c queue tail. Loop executes the above process until a or b, one queue is empty, and then copy another non-empty queue to c queue tail. Note: Do not allow the use of other algorithms (such as sorting algorithms). Try to create a class Com, completion of the merger work.
(如排序算法)。试建立一个类Com,完成合并工作。-The two were in ascending order of an ordered array of a and b copied into the first three ordered array, c. m and n are each a and b is the number of array elements, the result is the number of elements c k. For example, a and b respectively, the array {1,2, 2,3,8} and {3,4,7,8}, the resulting values of the array c is: {1,2,2,3,3,4 , 7,8,8). Algorithm is: a, b two elements of two arrays as two queues, comparing the first team will put the smaller end of the queue c, if the team' s first two elements are equal, first select a queue header element Join c queue tail. Loop executes the above process until a or b, one queue is empty, and then copy another non-empty queue to c queue tail. Note: Do not allow the use of other algorithms (such as sorting algorithms). Try to create a class Com, completion of the merger work.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
homework\2.cpp
homework