עליך להתחבר בכדי להוריד קבצים מהאתר
על מנת להבטיח שמשאבינו לא ינוצלו לרעה.
1 : using System;
2 : using System.Collections.Generic;
3 : using System.Linq;
4 : using System.Text;
5 : using System.Threading.Tasks;
6 :
7 : namespace GuessTheNumber
8 : {
9 : class Program
10 : {
11 : static void Main(string[] args)
12 : {
13 : int num_to_guess;
14 : int user_guess;
15 : int score = 0;
16 : Random rnd = new Random();
17 : for (int i = 0; i < 10; i++)
18 : {
19 : Console.WriteLine("Round Num {0}", i + 1);
20 : int trial_counter = 0;
21 : num_to_guess = rnd.Next(1, 100);
22 : do
23 : {
24 : user_guess = int.Parse(Console.ReadLine());
25 : trial_counter++;
26 : if (user_guess < num_to_guess)
27 : {
28 : Console.WriteLine("Select bigger num");
29 : }
30 : else if (user_guess > num_to_guess)
31 : {
32 : Console.WriteLine("Select smaller num");
33 : }
34 : }
35 : while (user_guess != num_to_guess && trial_counter < 5);
36 : if (user_guess == num_to_guess)
37 : {
38 : Console.WriteLine("hooray, hooray - user guess the correcr number - {0}", num_to_guess);
39 : score += 10;
40 : Console.WriteLine("SCORE - {0}", score);
41 : }
42 : else
43 : {
44 : Console.WriteLine("you failed - the number is {0}", num_to_guess);
45 : }
46 : }
47 : Console.WriteLine("you SCORE is {0}", score);
48 : }
49 : }
50 : }