using System.Net.Http.Headers;
using System.Security.Cryptography;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
string msg = "apple banana orange interface class static good";
Random random = new Random();
string[] words = msg.Split(' ');
int random_index = random.Next(words.Length);
string select_word = words[random_index];
Console.WriteLine(select_word);
char[] char_words = select_word.ToCharArray();
for(int i = 0; i < char_words.Length; i++)
{
char_words[i] = '-';
}
int guessTimes = 5;
while (guessTimes>0)
{
Console.WriteLine(char_words);
char guess_char = char.Parse(Console.ReadLine());
if (select_word.Contains(guess_char))
{
for (int i = 0; i < char_words.Length; i++)
{
if (select_word[i] == guess_char)
{
char_words[i] = guess_char;
}
}
if (!char_words.Contains('-'))
{
break;
}
}
else
{
guessTimes--;
}
}
if(guessTimes > 0)
{
Console.WriteLine("you win");
}
else
{
Console.WriteLine("you lose");
}
}
}
}
04-24
348
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-09
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交