Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class HayvanNumbers
- {
- static void Main()
- {
- int sum = int.Parse(Console.ReadLine());
- int diff = int.Parse(Console.ReadLine());
- string numberExistingChecker = null;
- for (int a = 5; a < 10; a++)
- {
- for (int b = 5; b < 10; b++)
- {
- for (int c = 5; c < 10; c++)
- {
- int abc = int.Parse(""+a+b+c);
- int def = abc + diff;
- int ghi = abc + 2 * diff;
- if (abc < def && def < ghi && (sumOfNumber(abc)+sumOfNumber(def)+sumOfNumber(ghi) == sum) &&
- isAllowednumber(abc) && isAllowednumber(def) && isAllowednumber(ghi))
- {
- Console.WriteLine("{0}{1}{2}", abc, def, ghi);
- numberExistingChecker = abc.ToString() + def + ghi;
- }
- }
- }
- }
- if (numberExistingChecker == null)
- {
- Console.WriteLine("No");
- }
- }
- static bool isAllowednumber(int n)
- {
- bool isAllowed = false;
- int thirdDigit = n % 10;
- n /= 10;
- int secondDigit = n % 10;
- n /= 10;
- int firstDigit = n % 10;
- if (thirdDigit != 0 && secondDigit != 0 && thirdDigit != 0)
- {
- isAllowed = true;
- }
- return isAllowed;
- }
- static int sumOfNumber(int n)
- {
- int thirdDigit = n % 10;
- n /= 10;
- int secondDigit = n % 10;
- n /= 10;
- int firstDigit = n % 10;
- int sum = firstDigit + secondDigit + thirdDigit;
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement