Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- public void Main(string[] args)
- {
- Console.WriteLine("Poses lekseis thes na dwseis?");
- int n = int.Parse(Console.ReadLine());
- string[] pinakas = new string[n];
- Console.WriteLine("Poies {0} lekseis thes?", n);
- for (int i=0; i<n; i++)
- {
- pinakas[i] = Console.ReadLine();
- }
- Random rnd = new Random();
- int num = rnd.Next(0, n);
- string word = pinakas[num];
- char[] guess = new char[word.Length];
- int lives = 6;
- Console.WriteLine("Dwse ena gramma");
- for (int i = 0; i < word.Length; i++)
- {
- guess[i] = '_';
- }
- while (true)
- {
- char userInput = char.Parse(Console.ReadLine());
- for (int j = 0; j < word.Length; j++)
- {
- if (userInput == word[j])
- {
- guess[j] = userInput;
- }
- else
- {
- Console.WriteLine("Wrong input. You have {0} remaining lives", lives);
- lives--;
- }
- }
- Console.Write(guess);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment