desislava_topuzakova

5. Winner Combinations

Dec 2nd, 2023
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography.X509Certificates;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace _05
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. int n = int.Parse(Console.ReadLine());
  16. int count = 0; //брой на печелившите числа
  17.  
  18. //[1000; 9999]
  19. for (int thousands = 1; thousands <= 9; thousands++) //хилядните
  20. {
  21. for (int hundreds = 1; hundreds <= 9; hundreds++) //стотици
  22. {
  23. for (int tens = 1; tens <= 9; tens++) //десетици
  24. {
  25. for (int units = 1; units <= 9; units++) //единици
  26. {
  27. //генерира четирицифрено число: {thousands}{hundreds}{tens}{units}
  28. //проверка дали е печелившо
  29. if (thousands + hundreds == n && tens % 2 == 0 && (units == 4 || units == 6))
  30. {
  31. //печелившо число
  32. count++;
  33. Console.Write($"{thousands}{hundreds}{tens}{units} ");
  34. }
  35. }
  36. }
  37. }
  38. }
  39.  
  40. //отпечатани всички печеливши числа
  41. Console.WriteLine(); //минава на нов ред
  42. Console.WriteLine($"Count of winner numbers: {count}");
  43.  
  44.  
  45. }
  46. }
  47. }
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment