slemiba

L04-01 Osztók-e?

Sep 27th, 2022 (edited)
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace SzTFLabor04
  4. {
  5.     class Program
  6.     {
  7.         static bool OsztoiE(int a, int b)
  8.         {
  9.             if (a % b == 0)
  10.             {
  11.                 return true;
  12.             }
  13.             if (b % a == 0)
  14.             {
  15.                 return true;
  16.             }
  17.             return false;
  18.         }
  19.         static void Main(string[] args)
  20.         {
  21.             Console.ForegroundColor = ConsoleColor.Black;
  22.             Console.BackgroundColor = ConsoleColor.White;
  23.             Console.Title = "SzTFLabor";
  24.             Console.Clear();
  25.  
  26.             Console.Write("A=? ");
  27.             int a = int.Parse(Console.ReadLine());
  28.             Console.Write("B=? ");
  29.             int b = int.Parse(Console.ReadLine());
  30.  
  31.             if (OsztoiE(a, b))
  32.             {
  33.                 Console.WriteLine("A két szám egymás osztói!");
  34.             }
  35.             else
  36.             {
  37.                 Console.WriteLine("A két szám nem egymás osztói!");
  38.             }
  39.  
  40.  
  41.         }
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment