Advertisement
frxbg

CheckNumbers

May 22nd, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CheckNumbers
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             for (int countM = 10; countM < 100; countM++) // Въртим цикъм за всички двуцифрени М числа от 10 до 99
  10.             {
  11.                 for (int countN = 10; countN <= 100; countN++) // Въртим цикъм за всички двуцифрени N числа от 10 до 99
  12.                 {
  13.                     int countA = (countM % 10) * 10 + (countM / 10); // Вземаме последната цифра от countM и я умножаваме по 10 след това я събираме с първата получена при целочислено деление
  14.                     int countB = (countN % 10) * 10 + (countN / 10);
  15.                    
  16.                     if ((countM * countN) == (countA * countB)) // Ако условието ни е вярно
  17.                     {
  18.                         Console.WriteLine($"{countM} * {countN} == {countA} * {countB}"); // Принтираме
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement