Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography.X509Certificates;
- using System.Text;
- using System.Threading.Tasks;
- namespace _05
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int count = 0; //брой на печелившите числа
- //[1000; 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++) //единици
- {
- //генерира четирицифрено число: {thousands}{hundreds}{tens}{units}
- //проверка дали е печелившо
- if (thousands + hundreds == n && tens % 2 == 0 && (units == 4 || units == 6))
- {
- //печелившо число
- count++;
- Console.Write($"{thousands}{hundreds}{tens}{units} ");
- }
- }
- }
- }
- }
- //отпечатани всички печеливши числа
- Console.WriteLine(); //минава на нов ред
- Console.WriteLine($"Count of winner numbers: {count}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment