Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 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 ConsoleApplication31
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] p = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  14. int e;
  15. Console.WriteLine("Please enter numbers between -9 to 9. Enter -1 to get to the end of the program.");
  16. e = int.Parse(Console.ReadLine());
  17. while (e < -9 || e > 9)
  18. {
  19. Console.WriteLine("Please re-enter the number, make sure it's between -9 to 9.");
  20. e = int.Parse(Console.ReadLine());
  21. }
  22. while (e != -1)
  23. {
  24. if (e == 9)
  25. {
  26. p[17]++;
  27. }
  28. if (e == 8)
  29. {
  30. p[16]++;
  31. }
  32. if (e == 7)
  33. {
  34. p[15]++;
  35. }
  36. if (e == 6)
  37. {
  38. p[14]++;
  39. }
  40. if (e == 5)
  41. {
  42. p[13]++;
  43. }
  44. if (e == 4)
  45. {
  46. p[12]++;
  47. }
  48. if (e == 3)
  49. {
  50. p[11]++;
  51. }
  52. if (e == 2)
  53. {
  54. p[10]++;
  55. }
  56. if (e == 1)
  57. {
  58. p[9]++;
  59. }
  60. if (e == 0)
  61. {
  62. p[8]++;
  63. }
  64. if (e == -2)
  65. {
  66. p[7]++;
  67. }
  68. if (e == -3)
  69. {
  70. p[6]++;
  71. }
  72. if (e == -4)
  73. {
  74. p[5]++;
  75. }
  76. if (e == -5)
  77. {
  78. p[4]++;
  79. }
  80. if (e == -6)
  81. {
  82. p[3]++;
  83. }
  84. if (e == -7)
  85. {
  86. p[2]++;
  87. }
  88. if (e == -8)
  89. {
  90. p[1]++;
  91. }
  92. if (e == -9)
  93. {
  94. p[0]++;
  95. }
  96. e = int.Parse(Console.ReadLine());
  97. while (e < -9 || e > 9)
  98. {
  99. Console.WriteLine("Please re-enter the number, make sure it's between -9 to 9.");
  100. e = int.Parse(Console.ReadLine());
  101. }
  102. }
  103. int maxValue = p.Max();
  104. int maxIndex = Array.IndexOf(p, maxValue);
  105. Console.WriteLine("The largest row of the same number entered one after the other lasted {0} numbers. The number was {1}.", maxValue, maxIndex - 8);
  106. }
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement