-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path028.cs
44 lines (34 loc) · 991 Bytes
/
028.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
Desafio 028
Problema: Escreva um programa que faça o computador "pensar"
em um número inteiro entre 0 e 5 e peça para o usuário
tentar descobrir qual foi o número escolhido pelo computador.
O programa deverá escrever na tela se o usuário venceu ou perdeu.
Resolução do problema:
*/
using System;
class io {
public static string input(string text) {
Console.Write(text);
return Console.ReadLine();
}
public static void print(object data, string end="\n") {
string text = data.ToString();
Console.Write($"{text}{end}");
}
}
class Program {
public static void Main () {
Random rng = new Random();
int maquina = rng.Next(0, 6);
int chute = int.Parse(io.input(
"Adivinhe o número um número entre 0 e 5: "
));
if (maquina == chute) {
io.print("Você acertou!");
}
else {
io.print($"Você errou. O número escolhido foi {maquina}");
}
}
}