Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LicensePlates
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var startText = Console.ReadLine();
  14. var endText = Console.ReadLine();
  15. var wishedPlates = int.Parse(Console.ReadLine());
  16.  
  17. var foundPlates = 0;
  18. for (int i = 1000; i <= 9999; i++)
  19. {
  20. if (foundPlates==wishedPlates)
  21. {
  22. Console.WriteLine();
  23. return;
  24. }
  25. var firstDigit = i/1000;
  26. var secondDigit = (i/100) % 10;
  27. var thirdDigit = (i / 10) % 10;
  28. var fourthDigit = i % 10;
  29. if (firstDigit + secondDigit + thirdDigit + fourthDigit == (firstDigit * thirdDigit) - wishedPlates)
  30. {
  31. Console.Write($"{startText}{i}{endText} ");
  32. foundPlates++;
  33. }
  34. }
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement