Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by nguhoa ( 5 years ago )
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
internal class Program
{
private static void Main(string[] args)
{
string n1, n2;
string t;
NhapTiep:
Console.WriteLine("Tro Choi Keo Bua Bao");
Console.WriteLine("++++++++++++++++");
Console.WriteLine("Yeu cau nhap mot trong ba: B (bua), K (keo), O (bao)");
n1 = NhapDuLieu(1);
n2 = NhapDuLieu(2);
// Xét dữ liệu
switch (n1)
{
case "B" when (n2 == "K"):
case "K" when (n2 == "O"):
case "O" when (n2 == "B"):
Console.WriteLine("1 Thang 2");
break;
case "B" when (n2 == "O"):
case "K" when (n2 == "B"):
case "O" when (n2 == "K"):
Console.WriteLine("1 Thua 2");
break;
default:
Console.WriteLine("Hoa");
break;
}
Console.WriteLine($"Tiep tuc nhap '1': ");
t = Console.ReadLine();
switch (t)
{
case "1":
goto NhapTiep;
}
Console.ReadKey();
}
private static string NhapDuLieu(int p)
{
string n;
Nhap:
Console.WriteLine($"Moi nguoi thu {p} nhap:");
n = Console.ReadLine();
switch (n)
{
case "B":
case "K":
case "O":
break;
default:
Console.WriteLine("Loi, vui long nhap dung yeu cau");
goto Nhap;
}
return n;
}
}
}
Revise this Paste