Advertisement
teotod

C# 20/100

Nov 1st, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 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 NumberGenerator
  8. {
  9. class NumberGenerator
  10. {
  11. static void Main(string[] args)
  12. {
  13. int m = int.Parse(Console.ReadLine());
  14. int n = int.Parse(Console.ReadLine());
  15. int l = int.Parse(Console.ReadLine());
  16. int specialNumber = int.Parse(Console.ReadLine());
  17. int controlNumber = int.Parse(Console.ReadLine());
  18. bool result1;
  19. bool result2 = false;
  20. for (int i = m; i >= 1; i--)
  21. {
  22. for (int j = n; j >= 1; j--)
  23. {
  24. for (int k = l; k >= 1; k--)
  25. {
  26. int sum = i + j + k;
  27. result1 = false;
  28. if (sum % 3 == 0 && !result1)
  29. {
  30. specialNumber += 5;
  31. result1 = true;
  32. }
  33. else if (sum % 10 == 5 && !result1)
  34. {
  35. specialNumber -= 2;
  36. result1 = true;
  37. }
  38. else if (sum % 2 == 0 && !result1)
  39. {
  40. specialNumber *= 2;
  41. }
  42. if (specialNumber >= controlNumber)
  43. {
  44. Console.WriteLine("Yes! Control number was reached! Current special number is "
  45. + specialNumber + ".");
  46. result2 = true;
  47. break;
  48. }
  49. }
  50. if (result2)
  51. {
  52. break;
  53. }
  54.  
  55. }
  56. if (result2)
  57. {
  58. break;
  59. }
  60. }
  61. if (!result2)
  62. {
  63. Console.WriteLine("No! {0} is the last reached special number.", specialNumber);
  64. }
  65.  
  66. }
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement