Author : Jisan
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-10370
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1311
Code:
import java.util.Scanner;
public class Uva_10370{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int cases = s.nextInt();
for(int i=0;i<cases;i++){
int n=s.nextInt();
int []jisan=new int[n];
int sum=0;
float avg=0;
for(int j=0;j<jisan.length;j++){
jisan[j]=s.nextInt();
sum+=jisan[j];
}
avg=(float)sum/n;
int count=0;
for(int j=0;j<jisan.length;j++){
if(jisan[j]>avg)
count++;
}
System.out.printf("%.3f%%%n", (float)count*100/n);
}
}
}
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-10370
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1311
Code:
import java.util.Scanner;
public class Uva_10370{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int cases = s.nextInt();
for(int i=0;i<cases;i++){
int n=s.nextInt();
int []jisan=new int[n];
int sum=0;
float avg=0;
for(int j=0;j<jisan.length;j++){
jisan[j]=s.nextInt();
sum+=jisan[j];
}
avg=(float)sum/n;
int count=0;
for(int j=0;j<jisan.length;j++){
if(jisan[j]>avg)
count++;
}
System.out.printf("%.3f%%%n", (float)count*100/n);
}
}
}
No comments:
Post a Comment