Advertisement
BloodMoonYTC

parosszamokAB

Oct 24th, 2021
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. namespace parosszamok
  4. {
  5.     class Program
  6.     {
  7.         static void szamok(int a, int b)
  8.         {
  9.             int i;
  10.             Console.WriteLine("A és B között a következő páros számok vannak: ");
  11.             for (i = a + 1; i < b; i++)
  12.             {
  13.                 if (i % 2 == 0)
  14.                     Console.WriteLine("{0}", i);
  15.             }
  16.         }
  17.         static void Main(string[] args)
  18.         {
  19.             int a, b;
  20.             Console.WriteLine("Írd be az A és B egész számokat, amelyekre érvényes A<B");
  21.             Console.Write("A = ");
  22.             a = int.Parse(Console.ReadLine());
  23.             while (a <= 0)
  24.             {
  25.                 Console.Write("A = ");
  26.                 a = int.Parse(Console.ReadLine());
  27.             }
  28.             Console.Write("B = ");
  29.             b = int.Parse(Console.ReadLine());
  30.             while (b <= 0)
  31.             {
  32.                 Console.Write("B = ");
  33.                 b = int.Parse(Console.ReadLine());
  34.             }
  35.             szamok(a, b);
  36.  
  37.             Console.WriteLine("Kólity Kristóf");
  38.             Console.WriteLine("Enter nyomásával újraindítható a program.");
  39.             Console.ReadLine();
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement