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 thousands = 1; thousands <= 9; thousands++)
- {
- for (int hundreds = 1; hundreds <= 9; hundreds++)
- {
- for (int tens = 1; tens <= 9; tens++)
- {
- for (int units = 1; units <= 9; units++)
- {
- //генерираме всички числа от 1111 до 9999
- 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($"{thousands}{hundreds}{tens}{units} ");
- }
- }
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment