Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class MaxSequence
- {
- static void Main(string[] args)
- {
- Console.Write("Enter size of the array: ");
- int n = int.Parse(Console.ReadLine());
- int[] array = new int[n];
- int[] maxSequence = new int[n];
- int m=0;
- int max=0;
- int ind = 0;
- for (int i = 0; i < n; i++)
- {
- array[i] = int.Parse(Console.ReadLine());
- }
- for (int j = 0; j < n-1; j++)
- {
- for (int k = j+1; k < n; k++)
- {
- if (array[j] == array[k])
- {
- maxSequence[m]=array[j];
- m++;
- }
- else
- {
- m = 0;
- break;
- }
- }
- }
- int p = maxSequence.Length;
- for (int l = 0; l < p; l++)
- {
- if (maxSequence[p-l-1] == 0)
- {
- ind++;
- }
- else
- {
- max = maxSequence[p-l-1];
- break;
- }
- }
- Console.WriteLine("Max sequence is:");
- for (int l = p - ind; l >= 0; l--)
- {
- Console.WriteLine("{0} ", max);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement