猜拳三局两胜
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int rcount = 0; int dncount = 0; for (int i = 0; i < 3; i++) { Console.Write("请输入(0 || 1 || 2分别代表剪刀||锤|| 布):"); int a = int.Parse(Console.ReadLine()); Random r = new Random(); int PC = r.Next(3); if (a >= 0 && a < 3) { if (PC - a == -1 || PC - a == 2) { Console.WriteLine("电脑出拳{0},你出拳{1}", PC, a+"赢了");//赢了 rcount++; } else if (PC == a ) { Console.WriteLine("电脑出拳{0},你出拳{1}", PC, a); i = i - 1; } else { Console.WriteLine("电脑出拳{0},你出拳{1}", PC, a+"输了"); dncount++; } } else { Console.WriteLine("请输入正确的数字!"); i = i - 1; } } if (rcount == 2) { Console.WriteLine("三局两胜,恭喜,你赢了!"); } else if (dncount == 2) { Console.WriteLine("三局两胜,你输了!"); } Console.ReadLine(); } } }