Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApp1
- {
- class Class1
- {
- static void Main(string[] args)
- {
- Random rnd = new Random();
- int x;
- x = rnd.Next(1, 101);
- //Console.WriteLine(x);
- int player = rnd.Next(2);
- Console.Write("Guess my number! Player {0} : ",player);
- int num = int.Parse(Console.ReadLine());
- int c = 1;
- while (num != x)
- {
- if (num < x)
- {
- Console.WriteLine("My Number is Greater than " + num);
- }
- else
- {
- Console.WriteLine("My Number is Lower than " + num);
- }
- if (player == 0)
- player = 1;
- else
- player = 0;
- Console.Write("Guess my number! player {0} : ",player);
- num = int.Parse(Console.ReadLine());
- c++;
- }
- Console.WriteLine();
- Console.WriteLine("Player{0} is the winner !", player);
- Console.WriteLine("Correct answer! my number is " + x);
- Console.WriteLine("You did it in {0} triales", c);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement