Advertisement
bodyquest

Singing Wheels

Oct 17th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 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 SongOfTheWheels
  8. {
  9. class SongOfTheWheels
  10. {
  11. static void Main(string[] args)
  12. {
  13. int num = int.Parse(Console.ReadLine());
  14. int count = 0;
  15. StringBuilder password = new StringBuilder();
  16.  
  17. for (int a = 1; a <= 9; a++)
  18. {
  19. for (int b = 1; b <= 9; b++)
  20. {
  21. for (int c = 1; c <= 9; c++)
  22. {
  23. for (int d = 1; d <= 9; d++)
  24. {
  25. if (num == a * b + c * d && a < b && c > d)
  26. {
  27. count++;
  28. Console.Write($"{a}{b}{c}{d} ");
  29. if (count == 4)
  30. {
  31. password.Append($"{a}{b}{c}{d}");
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }
  38. Console.WriteLine();
  39. if (count < 4)
  40. {
  41. Console.WriteLine("No!");
  42. }
  43. else
  44. {
  45. Console.WriteLine($"Password: {password}");
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement