int count1 = 0, Count2 = 0;//Sets the number of wins, the number of losses
for (;;)
{
1. Prompt the user to punch
Console.Write ("Please Punch (stone 0, scissors 1, Cloth 2):");
int yh = Int. Parse (Console.ReadLine ());
2, computer randomly generated
Random r = new Random ();
int DN = R.next (0, 3);
3. Judging winning or losing
User wins: 0-1=-1 1-2=-1 2-0=2
The user loses: 0-2=-2 1-0=1 2-1=1
Draw 0
int JG = YH-DN;
if (YH < 0 | | YH > 2)
{
Console.WriteLine ("Wrong input! ");
}
Else
{
if (jg = =-1 | | jg = = 2)
{
Console.WriteLine ("You won!" ");
count1++;
if (count1 = = 2)
{
Console.WriteLine ("You finally won!") "); break;//win two results, jump out of the loop
}
}
else if (jg = =-2 | | jg = = 1)
{
Console.WriteLine ("You Lost!" ");
count2++;
if (Count2 = = 2)
{
Console.WriteLine ("You end up losing!") "); Break
}
}
else if (jg = = 0)
{
Console.WriteLine ("Draw! ");
}
}
}
Console.ReadLine ();
Scissors expansion exercise, three innings and two wins