Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Riccardo {
- public static void main(String[] args) {
- Scanner kb = new Scanner(System.in);
- int num = kb.nextInt();
- int min = 0;
- int max = kb.nextInt();
- int val = 0;
- boolean primoGiro = true;
- for (int i = 0; i < num; i++, val = kb.nextInt()) {
- if (primoGiro || val > max) {
- max = val;
- }
- if (primoGiro || val < min) {
- min = val;
- }
- primoGiro = false;
- }
- int tot = 0;
- int confronti = 0;
- for (int i = min; i <= max; i++) {
- for (int j = 0; j <= max - min; j++, confronti++) {
- if (i > j) {
- tot++;
- }
- }
- }
- double rapporto = tot / (double)confronti;
- System.out.println("Tot: " + tot + "; rapporto: " + rapporto);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment