Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class Pr10KaminoFactory {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int seqCounter = 0;
- int seqLength = 0;
- int seqSum = 0;
- int seqFirstPosition = 0;
- while (true) {
- String inputLineArray = scanner.nextLine();
- if ("Clone them!".equals(inputLineArray)) {
- break;
- }
- int[] sequenceDNA = Arrays.stream(inputLineArray.split("!"))
- .mapToInt(Integer::parseInt)
- .toArray();
- for (int i = 0; i < sequenceDNA.length; i++) {
- if (sequenceDNA[i] == 1) {
- seqSum += sequenceDNA[i];
- seqCounter++;
- //seqFirstPosition = i - seqCounter;
- if (seqCounter > seqLength) {
- seqLength = seqCounter;
- } else {
- seqCounter = 0;
- }
- }
- }
- break;
- }
- System.out.println("seqSum " + seqSum);
- System.out.println("seqLength " + seqLength);
- System.out.println("seqFirstPosition " + seqFirstPosition);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement