使用单个语句使用rondom数字初始化数组 [英] Initialize array with rondom numbers with single statement
本文介绍了使用单个语句使用rondom数字初始化数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用C ++使用单个语句使用rondom数字初始化数组?
How to Initialize array with rondom numbers with single statement using C++ ?
推荐答案
什么是声明?如果你有一个的
语句包含一个赋值语句,那么是一个或两个语句吗?
我应该认为,如果你没有初始化数组,你会有相当随机的数字。 :耸耸肩:
听起来像家庭作业或谜题。
What''s a statement? If you have afor
statement that contains an assignment statement, is that one statement or two?
I should think that if you don''t initialize the array you''d have fairly random numbers. :shrug:
Sounds like homework or a puzzle or something.
这个怎么样:
How about this:
int values[5] = { rand() % 5, rand() % 5, rand() % 5, rand() % 5, rand() % 5};
看看这个,
< a href =http://www.cplusplus.com/forum/beginner/5527/> http://www.cplusplus.com/forum/beginner/5527/ [ ^ ]
这篇关于使用单个语句使用rondom数字初始化数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文