Advertisement
zornitza_gencheva

NineDigitNumbers_new

Apr 17th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 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 NineDigitNumbers
  8. {
  9. class NineDigitNumbers
  10. {
  11. static void Main(string[] args)
  12. {
  13. uint sum = uint.Parse(Console.ReadLine());
  14. uint diff = uint.Parse(Console.ReadLine());
  15. int flag = 0;
  16.  
  17. for (int a = 1; a <= 7; a++)
  18. {
  19. for (int b = 1; b <= 7; b++)
  20. {
  21. for (int c = 1; c <= 7; c++)
  22. {
  23. for (int d = 1; d <= 7; d++)
  24. {
  25. for (int e = 1; e <= 7; e++)
  26. {
  27. for (int f = 1; f <= 7; f++)
  28. {
  29. for (int g = 1; g <= 7; g++)
  30. {
  31. for (int h = 1; h <= 7; h++)
  32. {
  33. for (int i = 1; i <= 7; i++)
  34. {
  35. if (a + b + c + d + e + f + g + h + i == sum)
  36. {
  37. int first = int.Parse(a.ToString() + b.ToString() + c.ToString());
  38. int second = int.Parse(d.ToString() + e.ToString() + f.ToString());
  39. int third = int.Parse(g.ToString() + h.ToString() + i.ToString());
  40. if (third - second == diff && second - first == diff)
  41. {
  42. Console.WriteLine("{0}{1}{2}{3}{4}{5}{6}{7}{8}", a, b, c, d, e, f, g, h, i);
  43. flag++;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55.  
  56. if (flag == 0)
  57. {
  58. Console.WriteLine("No");
  59. }
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement