using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Feladat1() { int paros = 0; int paratlan = 1; for(int i = 1; i <= 9; ++i) { if (i % 2 == 0) { //paros paros += i; } else { paratlan *= i; } } Console.WriteLine($"A páros számok összege: {paros}"); Console.WriteLine($"A páratlan számok szorzata: {paratlan}"); paros = 0; paratlan = 1; int cntr = 1; while (cntr < 10) { if (cntr % 2 == 0) { //paros paros += cntr; } else { paratlan *= cntr; } ++cntr; } Console.WriteLine($"A páros számok összege: {paros}"); Console.WriteLine($"A páratlan számok szorzata: {paratlan}"); } static void Feladat2() { Console.WriteLine("Adj egy számot!"); string szam = Console.ReadLine(); Console.WriteLine($"A szám számjegyeinek száma: {szam.Length}"); int szam1 = Convert.ToInt32(szam); int cntr = 1; while (szam1 > 10) { szam1 /= 10; ++cntr; } Console.WriteLine($"A szám számjegyeinek száma: {cntr}"); } static void Feladat3() { int[] arr = new int[10]; for (int i = 0; i < arr.Length; ++i) { arr[i] = i * 2 + 2; } foreach (int x in arr) { Console.WriteLine($"{x}"); } } static void Feladat4() { Console.WriteLine("Add meg a testtömeged kg ban!"); double kg = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Add mega testmagasságod cm ben!"); double m = Convert.ToDouble(Console.ReadLine()) / 100; bool fiu = false; Console.WriteLine("Fiú vagy? i/n"); string lanye = Console.ReadLine(); if (lanye == "i") { fiu = true; } double bmi = kg / (m * m); if (fiu) { if (bmi < 19) { Console.WriteLine("Sovány"); } else { Console.WriteLine("Nem Sovány"); } } else { if (bmi < 19) { Console.WriteLine("Sovány"); } else { Console.WriteLine("Nem Sovány"); } } } static void Main(string[] args) { Feladat4(); Console.ReadKey(); } } }