Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- public static int Func (int num)
- {
- int ser = 1, prefSer = 1, pref = -1, cur;
- num *= 10;
- do
- {
- num /= 10;
- cur = num % 10;
- if(cur == pref)
- ser++;
- else
- {
- if(ser > prefSer)
- prefSer = ser;
- ser = 1;
- }
- pref = cur;
- }
- while (num > 10);
- return ser > prefSer ? ser : prefSer;
- }
- static void Main(string[] args)
- {
- int num;
- int.TryParse(Console.ReadLine(), out num);
- Console.WriteLine(Func(num));
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement