Skip to content

Instantly share code, notes, and snippets.

@pahaz
Forked from LevShab/Game.cs
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pahaz/67c9b7bab6db1b1bb143 to your computer and use it in GitHub Desktop.
Save pahaz/67c9b7bab6db1b1bb143 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game
{
class Program
{
static void Main(string[] args)
{
int round = 0;
int score = 0;
int random;
Console.WriteLine("Я хочу сыграть с тобой в одну игру, отгодай число от 0 до 100");
while(round != 10){
Random random_nenuzon = new Random(DateTime.Now.Millisecond);
random = random_nenuzon.Next(101); // Если хотим от 1 до 100 пишем в скобках - 1, 101
Console.WriteLine("Введи число");
int answer = Convert.ToInt32(Console.ReadLine());
if (answer == random) {
Console.WriteLine("Вы выйграли");
score++; //Это тоже самое что и score = score + 1
}else{
Console.WriteLine("Вы не выйграли");
}
round++;
Console.Write("Ваш счет на данный момент равен ");
Console.WriteLine(score);
Console.Write("Вы сыграли ");
Console.Write(round);
Console.WriteLine(" раундов из 10");
}
Console.Write("Вы сыграли со счетом ");
Console.Write(score);
Console.WriteLine(" баллов из 10");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment