Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication31
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] p = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- int e;
- Console.WriteLine("Please enter numbers between -9 to 9. Enter -1 to get to the end of the program.");
- e = int.Parse(Console.ReadLine());
- while (e < -9 || e > 9)
- {
- Console.WriteLine("Please re-enter the number, make sure it's between -9 to 9.");
- e = int.Parse(Console.ReadLine());
- }
- while (e != -1)
- {
- if (e == 9)
- {
- p[17]++;
- }
- if (e == 8)
- {
- p[16]++;
- }
- if (e == 7)
- {
- p[15]++;
- }
- if (e == 6)
- {
- p[14]++;
- }
- if (e == 5)
- {
- p[13]++;
- }
- if (e == 4)
- {
- p[12]++;
- }
- if (e == 3)
- {
- p[11]++;
- }
- if (e == 2)
- {
- p[10]++;
- }
- if (e == 1)
- {
- p[9]++;
- }
- if (e == 0)
- {
- p[8]++;
- }
- if (e == -2)
- {
- p[7]++;
- }
- if (e == -3)
- {
- p[6]++;
- }
- if (e == -4)
- {
- p[5]++;
- }
- if (e == -5)
- {
- p[4]++;
- }
- if (e == -6)
- {
- p[3]++;
- }
- if (e == -7)
- {
- p[2]++;
- }
- if (e == -8)
- {
- p[1]++;
- }
- if (e == -9)
- {
- p[0]++;
- }
- e = int.Parse(Console.ReadLine());
- while (e < -9 || e > 9)
- {
- Console.WriteLine("Please re-enter the number, make sure it's between -9 to 9.");
- e = int.Parse(Console.ReadLine());
- }
- }
- int maxValue = p.Max();
- int maxIndex = Array.IndexOf(p, maxValue);
- Console.WriteLine("The largest row of the same number entered one after the other lasted {0} numbers. The number was {1}.", maxValue, maxIndex - 8);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement