Elágazások
This commit is contained in:
10
VezSzerkezetek/Elagazasok/Elagazasok.csproj
Normal file
10
VezSzerkezetek/Elagazasok/Elagazasok.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
90
VezSzerkezetek/Elagazasok/Program.cs
Normal file
90
VezSzerkezetek/Elagazasok/Program.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
namespace Elagazasok
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Elágazások");
|
||||
|
||||
int szam = -10;
|
||||
|
||||
//egyszeres egyágú
|
||||
if (szam>=0)
|
||||
{
|
||||
Console.WriteLine("A szám pozitív");
|
||||
}
|
||||
|
||||
//egyszeres kétágú
|
||||
if (szam>=0)
|
||||
{
|
||||
Console.WriteLine("A szám pozitív");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("A szám negatív");
|
||||
}
|
||||
|
||||
//többszörös szelekciók
|
||||
int pontszam = 44;
|
||||
|
||||
if (pontszam>90)
|
||||
{
|
||||
Console.WriteLine("Jeles");
|
||||
} else if (pontszam > 75)
|
||||
{
|
||||
Console.WriteLine("Jó");
|
||||
} else if(pontszam > 60)
|
||||
{
|
||||
Console.WriteLine("Közepes");
|
||||
} else if( pontszam > 45)
|
||||
{
|
||||
Console.WriteLine("Elégséges");
|
||||
} else
|
||||
{
|
||||
Console.WriteLine("Elégtelen");
|
||||
}
|
||||
|
||||
//switch
|
||||
string nap = "hétfő";
|
||||
switch (nap)
|
||||
{
|
||||
case "hétfő":
|
||||
Console.WriteLine("Ma hétfő van");
|
||||
break;
|
||||
case "kedd":
|
||||
Console.WriteLine("Ma kedd van");
|
||||
break;
|
||||
|
||||
default:
|
||||
Console.WriteLine("Nem tudom milyen nap van ma.");
|
||||
break;
|
||||
}
|
||||
|
||||
string jegy = pontszam switch
|
||||
{
|
||||
<= 0 => "elégtelen",
|
||||
< 40 => "elégséges",
|
||||
< 60 => "közepes",
|
||||
< 75 => "jó",
|
||||
_ => "Jeles"
|
||||
|
||||
|
||||
};
|
||||
|
||||
string jegy2 = pontszam switch
|
||||
{
|
||||
>= 0 and <40 => "elégtelen",
|
||||
>= 40 and <=60 => "elégséges",
|
||||
>60 and <=75 => "közepes",
|
||||
>75 and <=90 => "jó",
|
||||
_ => "Jeles"
|
||||
|
||||
};
|
||||
|
||||
Console.WriteLine(jegy);
|
||||
|
||||
Console.WriteLine(jegy2);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user