注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 363853746 于 2011-9-26 05:35 编辑
• Problem # 1 [100 points]. Write a C++ program for creating and managing arrays of numbers. You
should use vectors (as seen in class, and defined by the C++ Standard Template Library) instead of
C-style arrays. The size of the array should be asked as input to the user. The program should use
a function to populate the vector with random elements (whether integers or real numbers) selected
randomly and uniformly in the range [0. . .M], where M is an integer asked as input to the user. You
should also define a function for checking whether an array is sorted or not and a function for printing
the array out.
All functions should be templatized, to manage vectors independently of the type of their elements.
The function main should ask the user for the size of the array, and test the defined function on
vectors with different kind of elements. It should also print out the size of the vectors, their smallest
and biggest elements and say whether they are sorted or not.
Be sure to follow the coding style introduced in class, and to properly comment your code.
Below is the framework that your should use for your program.
红色的那一部分是什么意思。是说产生几个数组,有的数组是int型,有的是real number,还是同一个数组里面既有int 又有real?
下午搞了出来,我是弄了几个函数模板来验证排序什么的,数组是自己定义的。 |