小编use*_*575的帖子

填充数组

你可以帮我解决用随机数填充5个圆圈阵列的问题.随机数将是圆的半径.这是我的代码:

#include <iostream>
#include <time.h>
using namespace std;

int main()
{
    // Array 2, below section is to populate the array with random radius
    float CircleArrayTwo [5]; // store the numbers
    const int NUM = 5; // Display 5 random numbers

    srand(time(NULL)); // seed the generator

    for(int i = 0; i < NUM; ++i)
    {
        CircleArrayTwo[i] = rand()%10;
    }

    cout << "Below is the radius each of the five circles in the second array. " <<   endl;
    cout << CircleArrayTwo …
Run Code Online (Sandbox Code Playgroud)

c++ arrays random

1
推荐指数
1
解决办法
2044
查看次数

标签 统计

arrays ×1

c++ ×1

random ×1