Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[] args)
- {
- System.out.print("Insert binary sequence: ");
- Scanner sc = new Scanner(System.in);
- String sseq = sc.nextLine();
- char[] cseq = sseq.toCharArray();
- int iseq;
- int count = 1, max = 1, temp = 2, type = 2;
- for(int i = 0; i < sseq.length(); i++)
- {
- iseq = Integer.parseInt(String.valueOf(cseq[i]));
- if(iseq == temp)
- {
- count++;
- }
- else
- {
- count = 1;
- }
- temp = iseq;
- if(count >= max)
- {
- max = count;
- type = iseq;
- }
- }
- System.out.println(type +"s have the biggest sequest. Length: " +max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement