Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Plateau {
- public static void main(String[] args) {
- if (args.length < 3) {
- System.out.println("ERROR");
- return;
- }
- int[] plateauWerte = new int[args.length];
- for (int i = 0; i < args.length; i++) {
- plateauWerte[i] = Integer.parseInt(args[i]);
- }
- int length = 0;
- int index = -1;
- boolean isPlateau = false;
- int tempLength = length;
- int tempInd = index;
- for (int i = 1; i < plateauWerte.length; i++) {
- if (plateauWerte[i] > plateauWerte[i - 1]) {
- isPlateau = true;
- tempInd = i;
- tempLength = 1;
- } else if (isPlateau && plateauWerte[i] == plateauWerte[i - 1]) {
- tempLength++;
- } else if (isPlateau && plateauWerte[i - 1] > plateauWerte[i]) {
- if (tempLength > length) {
- length = tempLength;
- index = tempInd;
- }
- isPlateau = false;
- }
- }
- if(index == -1 && length == 0){
- System.out.println("kein plateau");
- } else {
- System.out.println(index + " " + length);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement