C # Simple instances of handling scissors problems (non-form)
Scissors, 5 innings, 3 wins, requires the use of public variables.
Namespace structure Body Review _ Common variable {class Program {public int rz=0;
public int dz = 0;
public string BJ (int a, int b) {int d = a-b; if (d==-2| |
D==1) {return "person"; else if (d==2| |
D==-1) {return "computer";
else {return "and";
} static void Main (string[] args) {Random SJ = new Random ();
Program Zdy=new ();
while (Zdy.rz < 3 && Zdy.dz < 3) {Console.WriteLine ("Please enter the number of scissors stone cloth (1 for scissors, 2 for stone, 3 for cloth):"); int a = Int.
Parse (Console.ReadLine ()); int b = SJ.
Next (1,4);
String JG = ZDY.BJ (A, b);
Switch (JG) {case "person": zdy.rz++;
Console.WriteLine ("You win this Council");
Break
Case "Computer": zdy.dz++;
Console.WriteLine ("Computer wins in this Council");
Break Case "and": Console.writelINE ("This council draws");
Break
} if (Zdy.rz > Zdy.dz) {Console.WriteLine ("You Won");
else {Console.WriteLine ("You Lost");
} console.readline ();
}
}
}
Above this C # processing scissors problem Simple example (non-form) is a small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.