Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO.IsolatedStorage;
- namespace NestedLoops
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- //1111 до 9999
- for (int number = 1111; number <= 9999; number++)
- {
- //проверка дали е специално:
- //вземе всяка една от цифрите ->
- int thousands = number / 1000;
- int hundreds = (number / 100) % 10;
- int tens = (number / 10) % 10;
- int units = number % 10;
- //проверка да е специално -> n % == 0
- bool check1 = thousands != 0 && n % thousands == 0;
- bool check2 = hundreds != 0 && n % hundreds == 0;
- bool check3 = tens != 0 && n % tens == 0;
- bool check4 = units != 0 && n % units == 0;
- //специално ако са изпълнени 4-те неща
- if(check1 && check2 && check3 && check4)
- {
- Console.Write(number + " ");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment