Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LicensePlates
- {
- class Program
- {
- static void Main(string[] args)
- {
- var startText = Console.ReadLine();
- var endText = Console.ReadLine();
- var wishedPlates = int.Parse(Console.ReadLine());
- var foundPlates = 0;
- for (int i = 1000; i <= 9999; i++)
- {
- if (foundPlates==wishedPlates)
- {
- Console.WriteLine();
- return;
- }
- var firstDigit = i/1000;
- var secondDigit = (i/100) % 10;
- var thirdDigit = (i / 10) % 10;
- var fourthDigit = i % 10;
- if (firstDigit + secondDigit + thirdDigit + fourthDigit == (firstDigit * thirdDigit) - wishedPlates)
- {
- Console.Write($"{startText}{i}{endText} ");
- foundPlates++;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement