Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Guess-the-number/C-sharp/guess-the-number-1.cs
Normal file
19
Task/Guess-the-number/C-sharp/guess-the-number-1.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
|
||||
class GuessTheNumberGame
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
int randomNumber = new Random().Next(1, 11);
|
||||
|
||||
Console.WriteLine("I'm thinking of a number between 1 and 10. Can you guess it?");
|
||||
while(true)
|
||||
{
|
||||
Console.Write("Guess: ");
|
||||
if (int.Parse(Console.ReadLine()) == randomNumber)
|
||||
break;
|
||||
Console.WriteLine("That's not it. Guess again.");
|
||||
}
|
||||
Console.WriteLine("Congrats!! You guessed right!");
|
||||
}
|
||||
};
|
||||
26
Task/Guess-the-number/C-sharp/guess-the-number-2.cs
Normal file
26
Task/Guess-the-number/C-sharp/guess-the-number-2.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System; using System.Text; //daMilliard.cs
|
||||
namespace DANILIN
|
||||
|
||||
{ class Program
|
||||
{ static void Main(string[] args)
|
||||
{ Random rand = new Random();int t=0;
|
||||
int h2=100000000; int h1=0; int f=0;
|
||||
int comp = rand.Next(h2);
|
||||
int human = rand.Next(h2);
|
||||
|
||||
while (f<1)
|
||||
{ Console.WriteLine();Console.Write(t);
|
||||
Console.Write(" ");Console.Write(comp);
|
||||
Console.Write(" ");Console.Write(human);
|
||||
|
||||
if(comp < human)
|
||||
{ Console.Write(" MORE");
|
||||
int a=comp; comp=(comp+h2)/2; h1=a; }
|
||||
|
||||
else if(comp > human)
|
||||
{ Console.Write(" less");
|
||||
int a=comp; comp=(h1+comp)/2; h2=a;}
|
||||
|
||||
else {Console.Write(" win by ");
|
||||
Console.Write(t); Console.Write(" steps");f=1;}
|
||||
t++; }}}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue