用C#写一个猜谜游戏
命名空间W23
{
Class begin1 //定义一个begin1的类;//
{
公共静态void Main() // main函数//
{
int rock 1 = 3;//rock代表石头//
int Jian 1 = 2;//jian代表剪刀//
int bu 1 = 1;//bu代表布//
系统。随机rnd =新系统。random();
字符串aj =控制台。ReadLine();
int nbr=(int) rnd。下一个(1,3);//随机数//
字符串rnd1=Convert。ToString(NBR);//将rnd的int转换成string//
弦摇滚=转换。ToString(rock 1);//同上//
字符串jian=Convert。ToString(Jian 1);//同上//
字符串bu=Convert。ToString(bu 1);
if((rnd 1 = = rock)& amp;& amp(aj = = bu)| |(rnd 1 = = Jian)& amp;& amp(aj = = rock)| |(rnd 1 = = bu)& amp;& amp(aj==jian))
{
控制台。WriteLine("你赢了!");
}
if((rnd 1 = = rock)& amp;& amp(aj = = Jian)| |(rnd 1 = = Jian)& amp;& amp(aj = = bu)| |(rnd 1 = = bu)& amp;& amp(aj==rock))
{
控制台。WriteLine(“我出来了!”);
}
if((rnd 1 = = rock)& amp;& amp(aj = = rock)| |(rnd 1 = = Jian)& amp;& amp(aj = = Jian)| |(rnd 1 = = bu)& amp;& amp(aj==bu))
{
控制台。WriteLine("我被绑了!");
}
}
}
}