-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<RootNamespace>_005_app5_max_min</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
namespace _005_app5_max_min; | ||
|
||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
string repeate = "a"; | ||
bool valid = true; | ||
while (repeate.Equals("a")) | ||
{ | ||
Console.Clear(); | ||
Console.WriteLine("********************************"); | ||
Console.WriteLine("******** Lukáš Moravec *********"); | ||
|
||
int count, minSet, maxSet; | ||
int min = Int32.MaxValue, max = Int32.MinValue; | ||
int minPos = -1, maxPos = -1; | ||
|
||
Console.Write("Zadejte počet čísel k vygenerování N (celé číslo): "); | ||
while (!int.TryParse(Console.ReadLine(), out count)) | ||
Console.Write("Chybně zadané celé číslo!! \nZadejte znovu: "); | ||
|
||
do | ||
{ | ||
if (!valid) | ||
Console.WriteLine("\n!!! Spodní mez musí být menší než horní mez !!!\n"); | ||
|
||
Console.Write("Zadejte dolní mez (celé číslo): "); | ||
while (!int.TryParse(Console.ReadLine(), out minSet)) | ||
Console.Write("Chybně zadané celé číslo!! \nZadejte znovu: "); | ||
|
||
Console.Write("Zadejte horní mez (celé číslo): "); | ||
while (!int.TryParse(Console.ReadLine(), out maxSet)) | ||
Console.Write("Chybně zadané celé číslo!! \nZadejte znovu: "); | ||
|
||
valid = minSet < maxSet; | ||
} | ||
while (!valid); | ||
|
||
int[] output = new int[count]; | ||
|
||
Console.WriteLine("Konfigurace generátoru je počet čísel: {0}, horní mez: {1}, dolní mez {2}", count, maxSet, minSet); | ||
|
||
Random random = new Random(); | ||
|
||
Console.WriteLine("\nNáhodná čísla: "); | ||
for (int i = 0; i < output.Length; i++) | ||
{ | ||
output[i] = random.Next(minSet, maxSet + 1); | ||
Console.Write(" {0} ", output[i]); | ||
|
||
if (output[i] < min) | ||
{ | ||
min = output[i]; | ||
minPos = i; | ||
} | ||
if (output[i] > max) | ||
{ | ||
max = output[i]; | ||
maxPos = i; | ||
} | ||
} | ||
Console.WriteLine(); | ||
|
||
Console.WriteLine("\nČíselná řada má takovéto vlastnosti: "); | ||
Console.WriteLine($"Nejmenší hodnota: {min}, na pozici: {minPos}"); | ||
Console.WriteLine($"Nejvyšší hodnota: {max}, na pozici: {maxPos}"); | ||
|
||
Console.ReadKey(); | ||
} | ||
} | ||
} |