mardi 28 juin 2016

runtime error in ideone [duplicate]

This question already has an answer here:

import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int arr[] = new int[n];
        for(int i = 0 ; i < n ; i++){
        arr[i] = sc.nextInt();
     }

        for(int i = 0 ; i < n ; i++){
        arr[i] = Math.abs(arr[i + 0] - arr [i + 1]);
        }
        Arrays.sort(arr);
        System.out.println(arr[arr.length-1]);



      }

I am beginner of java and trying to learn coding.I was trying to find maximum no in array element difference but while running ideone is Giving Run time Error

Aucun commentaire:

Enregistrer un commentaire