Skip to content

Commit e7f03fa

Browse files
committed
Add conference 3
1 parent 02b35d3 commit e7f03fa

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
3+
class Program
4+
{
5+
static void Main(string[] args)
6+
{
7+
int min = int.Parse(args[0]);
8+
int max = int.Parse(args[1]);
9+
10+
Console.WriteLine($"Piensa un número entre {min} y {max}.");
11+
Console.WriteLine("Presiona ENTER cuando estés list@.");
12+
Console.ReadLine();
13+
14+
while (min < max)
15+
{
16+
int mid = (min + max) / 2;
17+
18+
Console.WriteLine($"¿Es tu número m[a]yor, m[e]nor, o [i]gual a {mid}?");
19+
char c = Console.ReadKey(true).KeyChar;
20+
21+
switch(c) {
22+
case 'a':
23+
min = mid + 1;
24+
break;
25+
case 'e':
26+
max = mid - 1;
27+
break;
28+
case 'i':
29+
Console.WriteLine($"¡Tu número es {mid}!");
30+
return;
31+
default:
32+
Console.WriteLine("Respuesta inválida. Inténtalo de nuevo.");
33+
break;
34+
}
35+
}
36+
37+
if (min == max)
38+
{
39+
Console.WriteLine($"¡Tu número es {min}!");
40+
}
41+
else
42+
{
43+
Console.WriteLine("Has hecho trampa, pillín...");
44+
}
45+
}
46+
}
47+
48+
// EJERCICIOS
49+
50+
// Modifica el programa para que no necesite saber de antemano
51+
// el número máximo. ¡Puede ser cualquier número!
52+
// Trata de resolverlo en la menor cantidad de preguntas.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "guesser", "guesser\guesser.csproj", "{785A00A5-4B2F-4C6B-B0CB-61E615CF918A}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{785A00A5-4B2F-4C6B-B0CB-61E615CF918A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{785A00A5-4B2F-4C6B-B0CB-61E615CF918A}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{785A00A5-4B2F-4C6B-B0CB-61E615CF918A}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{785A00A5-4B2F-4C6B-B0CB-61E615CF918A}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal

0 commit comments

Comments
 (0)