tuzikyy 2015-11-20 12:59 采纳率: 50%

# c#入门级问题求大手子解决

Random r = new Random();
int d1 = r.Next( 1, 7 );
int d2 = r.Next( 1, 7 );
int sum = d1 + d2;
Console.WriteLine("Player rolled {0} + {1} = {2}",d1, d2, sum);
switch (sum)
{
case 11:
Console.WriteLine("player win");
break;
case 7:
Console.WriteLine("player win");
break;
case 2:
Console.WriteLine("player lose");
break;
case 3:
Console.WriteLine("player lose");
break;
case 12:
Console.WriteLine("player lose");
break;
default :
Console.WriteLine("Point is {0}", sum);
break;
}
if (sum != 11||sum != 12||sum !=7||sum != 2||sum !=3)
{
int q1 = r.Next(1, 7);
int q2 = r.Next(1, 7);
int o = q1 + q2;
Console.WriteLine("Player rolled {0} + {1} = {2}", q1, q2, o);
if (o == sum)
{
Console.WriteLine("player win");
}
while (o != sum)
{
int y1 = r.Next(1, 7);
int y2 = r.Next(1, 7);
int s = y1 + y2;
Console.WriteLine("Player rolled {0} + {1} = {2}", y1, y2, s);
o = s;
if (s == sum)
{
Console.WriteLine("player win");
break;
}
else if (s == 7)
{
Console.WriteLine("player lose");
break;
}
}
}
Random r = new Random();
int d1 = r.Next( 1, 7 );
int d2 = r.Next( 1, 7 );
int sum = d1 + d2;
Console.WriteLine("Player rolled {0} + {1} = {2}",d1, d2, sum);
switch (sum)
{
case 11:
Console.WriteLine("player win");
break;
case 7:
Console.WriteLine("player win");
break;
case 2:
Console.WriteLine("player lose");
break;
case 3:
Console.WriteLine("player lose");
break;
case 12:
Console.WriteLine("player lose");
break;
default :
Console.WriteLine("Point is {0}", sum);
break;
}
if (sum != 11||sum != 12||sum !=7||sum != 2||sum !=3)
{
int q1 = r.Next(1, 7);
int q2 = r.Next(1, 7);
int o = q1 + q2;
Console.WriteLine("Player rolled {0} + {1} = {2}", q1, q2, o);
if (o == sum)
{
Console.WriteLine("player win");
}
while (o != sum)
{
int y1 = r.Next(1, 7);
int y2 = r.Next(1, 7);
int s = y1 + y2;
Console.WriteLine("Player rolled {0} + {1} = {2}", y1, y2, s);
o = s;
if (s == sum)
{
Console.WriteLine("player win");
break;
}
else if (s == 7)
{
Console.WriteLine("player lose");
break;
}
}
}
Random r = new Random();
int d1 = r.Next( 1, 7 );
int d2 = r.Next( 1, 7 );
int sum = d1 + d2;
Console.WriteLine("Player rolled {0} + {1} = {2}",d1, d2, sum);
switch (sum)
{
case 11:
Console.WriteLine("player win");
break;
case 7:
Console.WriteLine("player win");
break;
case 2:
Console.WriteLine("player lose");
break;
case 3:
Console.WriteLine("player lose");
break;
case 12:
Console.WriteLine("player lose");
break;
default :
Console.WriteLine("Point is {0}", sum);
break;
}
if (sum != 11||sum != 12||sum !=7||sum != 2||sum !=3)
{
int q1 = r.Next(1, 7);
int q2 = r.Next(1, 7);
int o = q1 + q2;
Console.WriteLine("Player rolled {0} + {1} = {2}", q1, q2, o);
if (o == sum)
{
Console.WriteLine("player win");
}
while (o != sum)
{
int y1 = r.Next(1, 7);
int y2 = r.Next(1, 7);
int s = y1 + y2;
Console.WriteLine("Player rolled {0} + {1} = {2}", y1, y2, s);
o = s;
if (s == sum)
{
Console.WriteLine("player win");
break;
}
else if (s == 7)
{
Console.WriteLine("player lose");
break;
}
}
}

• 写回答

#### 1条回答默认 最新

• Revolution_lxx 2015-11-20 13:07
关注

if (sum != 11||sum != 12||sum !=7||sum != 2||sum !=3)

=====================>>>>>>>>>>>>

if (sum != 11 && sum != 12 && sum !=7 && sum != 2 && sum !=3)

大兄弟 你短路了。。。

本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论

#### 悬赏问题

• ¥100 需求高精度PT100设计电路和算法
• ¥15 单片机配网，继电器开关，广播
• ¥60 Qcustomplot绘制实时动态曲线
• ¥20 运用matlab画x-y图
• ¥15 用idea运行项目，运行tomcat报错：断言失败
• ¥15 Sqlserver查询链接服务器数据问题
• ¥15 Bibtex4Word 引用中文文献
• ¥20 用opencv c/c++ 转换成灰度图，然后做一下直方图均衡，输出mp4文件
• ¥20 matlab中的双层数值积分
• ¥50 服务器打印水晶报表问题