Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- double avg = 0;
- int[] arr = new int[n];
- arr[0] = sc.nextInt();
- for (int i = 1; i < n; i++)
- {
- arr[i] = sc.nextInt();
- avg += Math.abs(arr[i] - arr[i - 1]);
- }
- System.out.printf("%.2f\n", avg / (n - 1));
Advertisement
Add Comment
Please, Sign In to add comment