static void Main (string[] args)
{
while (true)//Always loops
{
Random r = new random ();//Create stochastic function R
int[] Caipiao = new int[7];//Create array Caipiao with 7 elements
for (int i = 0; i < 6;) The For loop assigns a value to the red ball
{
if (i = = 0)//value of the first red ball
{
Caipiao[i] = R.next (1, 34);//Assign a value of caipiao[0] element between the random function value 1-33
i++;//i++
}
Else
{
int temp = R.next (1, 34);//create a temporary variable with a value of random 1-33
for (int j = 0; J < i;) Iterating through the elements of the Caipiao array 0-i bit
{
if (Temp==caipiao[j])//Compare TEMP variable temp to caipiao[j] value is equal
{
temp = R.next (1, 34);//If equality is re-assigned to temp,
j = 0; and change the value of J to 0 and compare it with temp from scratch
}
Else
{
j + +; J + + If there is no repetition
}
}
Caipiao[i] = temp; Assign temp to Caipiao[i] element when ending a loop comparison
i++; i++
}
}
for (int i = 0; i < Caipiao. Length-1; i++)//bubble Sort!
{
for (int j = i+1; J < Caipiao. Length-1; J + +)
{
int temp1 = 0;
if (Caipiao[i] > Caipiao[j])
{
Temp1 = Caipiao[i];
Caipiao[i] = Caipiao[j];
CAIPIAO[J] = Temp1;
}
}
}
CAIPIAO[6] = R.next (1, 17);//Blue Ball Assignment
for (int i = 0; i < Caipiao. Length; i++)//loop out all values
{
if (i==6)
{
Console.Write ("Blue ball:" +caipiao[i] + "\ t");
}
Else
{
Console.Write (Caipiao[i] + "\ t");
}
}
Console.WriteLine ();
String Y= "";
ArrayList al = new ArrayList ();
Al. ADD (3);
Al. ADD (5);
Al. ADD (7);
Al. Insert (1, 9);
for (int i = 0; i < al. Count; i++)
//{
Console.WriteLine (Al[i]);
//}
Console.ReadLine ();
}
}
C # Basic Eighth lecture