c# 入门 猜拳小游戏 怎么实现 出拳时按错了能重新出拳 谢谢了

for (c = 1; c > 0; c++) {
Console.WriteLine (“猜拳”);
Console.WriteLine (“猜拳游戏开始”);
Console.WriteLine (“请输入用户名”);
string yy = Console.ReadLine ();
for (int f = 1; f > 0; f++) {
for (int d = 1; d > 0; d++) {
Console.WriteLine (“请选择对手:1.爱情 2.家庭 3.事业”);
string y1 = Console.ReadLine ();
int q1 = int.Parse (y1);
switch (q1) {
case 1:
Console.WriteLine (“您确定对手为爱情吗? 1表示确定 其它数字表示否定”);
break;
case 2:
Console.WriteLine (“您确定对手为家庭吗? 1表示确定 其它数字表示否定”);
break;
case 3:
Console.WriteLine (“您确定对手为事业吗? 1表示确定 其它数字表示否定”);
break;
default :
Console.WriteLine (“请重新选择对手”);
continue;
}
break;
}
string y2 = Console.ReadLine ();
int q2 = int.Parse (y2);
switch (q2) {
case 1:
Console.WriteLine (“请阅读出拳规则 1代表剪刀 2代表石头 3代表布”);
break;
default :
Console.WriteLine (“请重新选择对手”);
continue;
}
break;
}
Console.WriteLine (“请出拳”);
string y3 = Console.ReadLine ();
int q3 = int.Parse (y3);
switch (q3) {
case 1:
Console.WriteLine (“您出的剪刀”);
break;
case 2:
Console.WriteLine (“您出的石头”);
break;
case 3:
Console.WriteLine (“您出的布”);
break;
default:
Console.WriteLine (“您按错了,请重新开始”);
continue;
}
Random ran = new Random ();
int R = ran.Next (1, 3);
switch (R) {
case 1:
Console.WriteLine (“对手出的是剪刀”);
break;
case 2:
Console.WriteLine (“对手出的是石头”);
break;
case 3:
Console.WriteLine (“对手出的是布”);
break;
default:
break;
}
if (R == q3)
Console.WriteLine (“平局”);
else if (q3 - R == 1||R - q3 == 2)
Console.WriteLine (“您赢了”);
else
Console.WriteLine (“您输了”);
Console.WriteLine (“是否继续 继续按1 停止按2”);
string y4 = Console.ReadLine ();
int q4 = int.Parse (y4);
switch (q4) {
case 1:
continue;
case 2:
return;
}
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值