赞
踩
using System;
namespace Project2
{
class Program
{
static void Main(string[] args)
{
int[] myArray = new int[5];
int i, m, n, j;
n = 0;
for (i = 0; i <= 4; i++)
{
Random random = new Random();
myArray[i] = random.Next(0, 13);
if (myArray[i] == 0)
{
n++;
}
}
for (i = 0; i <= 4; i++)
{
if (myArray[i] > 1 && myArray[i] < 11)
Console.Write(myArray[i] + " ");
if (myArray[i] == 11)
Console.Write("J" + " ");
if (myArray[i] == 12)
Console.Write("Q" + " ");
if (myArray[i] == 13)
Console.Write("K" + " ");
if (myArray[i] == 0)
Console.Write("王"+ " ");
if(myArray [i]==1)
Console.Write("A" + " ");
}
for (i = 0; i <= 3; i++)
{
for (j = i + 1; j <= 4; j++)
{
if (myArray[i] > myArray[j])
{
m = myArray[j];
myArray[j] = myArray[i];
myArray[i] = m;
}
if (myArray[i] == myArray[j] && myArray[i] != 0)
{
Console.WriteLine("不是顺子");
return;
}
if (n > 2)
{
Console.WriteLine("不是顺子");
return;
}
}
}
for (i = 0; i <= 3; i++)
{
if (myArray[i] != 0)
{
if (myArray[4] - myArray[i] <= 5 - n)
{
Console.WriteLine("是顺子");
return;
}
else
{
Console.WriteLine("不是顺子");
return;
}
}
}
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。