UVA – 10370 – Above Average


import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		while (T-- != 0) {
			int count = 0, N = in.nextInt(), a[] = new int[N];
			double avg = 0;
			for (int i = 0; i < N; avg += a[i], i++)
				a[i] = in.nextInt();

			avg /= N;

			for (int e : a)
				count += (e > avg) ? 1 : 0;

			double p = count;
			p /= N;
			System.out.format("%.3f", p * 100.00);
			System.out.println("%");
		}

	}
}

Advertisements

2 thoughts on “UVA – 10370 – Above Average

  1. Ahmed Salama says:

    You can printf “%.3f%%” instead of printing it in a new print method ..

  2. belbesy says:

    Thanks dear 🙂 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: