ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1457. Heating Main

easy[Java]
Posted by Evgeniy[VVV] 18 Aug 2014 19:26
cycle for,no more.

import java.util.Scanner;
public class easys {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int sum = 0;
int curr = 0;
double result = 0.0;
for(int i=0;i<N;i++){
curr = in.nextInt();
sum = sum + curr;

}
result = (double)sum/N;
System.out.printf("%.6f",result);

}

}
Re: easy[Java]
Posted by Bahodir | TUIT | 15 Dec 2014 00:43
public class HeatingMain1457_Accepted {
public static void main(String[] args) {
PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
Scanner x = new Scanner(System.in);
short  n = x.nextShort();
double s = 0;
for (int i = 0; i < n; i++) {
s += x.nextInt();
}
writer.printf("%.6f", s / n);
writer.close();
}
}