Gyakorlás
This commit is contained in:
58
Tombok2/Tombok2/Program.cs
Normal file
58
Tombok2/Tombok2/Program.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
namespace Tombok2
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
int[] szamok = new int[100];
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
for (int i = 0; i < szamok.Length; i++)
|
||||
{
|
||||
szamok[i] = random.Next(10, 100 + 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < szamok.Length; i++)
|
||||
{
|
||||
Console.Write(szamok[i] + " ");
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
//összegzés
|
||||
int osszeg = 0;
|
||||
for (int i = 0; i < szamok.Length; i++)
|
||||
{
|
||||
osszeg += szamok[i];
|
||||
}
|
||||
Console.WriteLine($"Összeg:{osszeg},{szamok.Sum()}");
|
||||
|
||||
//megszámlálás
|
||||
int darab = 0;
|
||||
for (int i = 0; i < szamok.Length; i++)
|
||||
{
|
||||
darab += 1;
|
||||
}
|
||||
Console.WriteLine($"Darab:{darab},{szamok.Count()}");
|
||||
|
||||
//min, max
|
||||
int min = szamok[0];
|
||||
int max = szamok[0];
|
||||
|
||||
for (int i = 0; i < szamok.Length; i++)
|
||||
{
|
||||
if (szamok[i]<min)
|
||||
{
|
||||
min = szamok[i];
|
||||
}
|
||||
if (szamok[i]>max)
|
||||
{
|
||||
max = szamok[i];
|
||||
}
|
||||
}
|
||||
Console.WriteLine($"Min:{min},Max:{max}");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Tombok2/Tombok2/Tombok2.csproj
Normal file
10
Tombok2/Tombok2/Tombok2.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user