📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
查看: 2579| 回复: 2
跳转到指定楼层
上一主题 下一主题
收起左侧

C++基础题,小疑问求解

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

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?
下午搞了出来,我是弄了几个函数模板来验证排序什么的,数组是自己定义的。

上一篇:特殊数组排序
下一篇:Facebook : Find largest number of dis-intersect segments
🔗
imwmwm 2011-9-26 04:15:10 | 只看该作者
全局:
就是要让你写一个程序 这个程序接收用户输入M和size of vector; 然后随机的生成size of vector个[0,M]之间的有理数填到这个vector里面 我对C++不是很熟 所以后面模板方法什么的..楼下继续
回复

使用道具 举报

🔗
 楼主| 363853746 2011-9-26 05:33:40 | 只看该作者
全局:
就是要让你写一个程序 这个程序接收用户输入M和size of vector; 然后随机的生成size of vector个[0,M]之间的有理数填到这个vector里面 我对C++不是很熟 所以后面模板方法什么的..楼下继续
imwmwm 发表于 2011-9-26 04:15



    谢啦,刚刚搞了一下午才搞出来
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表