Lab 3[continue] : Task#2 - Write a function to create random values in an array (duplicate values are allowed)
int n=10;
void setup()
{
int[] x=new int[n];
for(int i=0;i<n;i++)
{x[i]=-1;}
for(int i=0;i<n;i++)
{x[i]=random_array(x);}
for(int i=0;i<n;i++)
{println("x["+i+"] = "+x[i]);}
}
int random_array(int[] x)
{
int y;
y=round(random(0,n));
return y;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น