你能帮我解决一个用随机数填充 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 << endl;
system("PAUSE");
return 0;
}
目前输出如下:
下面是第二个数组中五个圆的半径。002CF878
我哪里错了?
任何帮助深表感谢