Elágazások

This commit is contained in:
Kovács Rudolf
2026-09-18 09:39:52 +02:00
parent daf8ea4127
commit fb74870792
4 changed files with 111 additions and 0 deletions

View 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>

View 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);
}
}
}

View File

@@ -1,3 +1,4 @@
<Solution>
<Project Path="Elagazasok/Elagazasok.csproj" Id="4e0dbece-9e0f-4d68-8a0d-fd8bddb84763" />
<Project Path="VezSzerkezetek/VezSzerkezetek.csproj" />
</Solution>

View File

@@ -45,6 +45,16 @@
}
Console.WriteLine();
//do-while
szamlalo = 0;
do
{
Console.Write(nevek[szamlalo]+" ");
szamlalo++;
}
while (szamlalo<nevek.Length);
Console.WriteLine();
}