package com.codegym.task.task05.task0532;
import java.io.*;
/*
Task about algorithms
*/
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
double[] g;
for (int i=0;i<n;i++){
g[i]=in.nextDouble();
}
double f=Double.MIN_VALUE;
for (int i=0;i<n;i++){
if(f<g[i])f=g[i];
}
System.out.println(f);
}
}
Uh... variable g might not hapackage com.codegym.task.task05.task0532;
import java.io.*;
/*
Task about algorithms
*/
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
double[] g;
for (int i=0;i<n;i++){
g[i]=in.nextDouble();
}
double f=Double.MIN_VALUE;
for (int i=0;i<n;i++){
if(f<g[i])f=g[i];
}
System.out.println(f);
}
}
Variable g might not have been initialized
Compiler Issues
Archived
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
6 May 2019, 06:09solution
You can not use an array like that without initializing it first. Fix this on the line:
I would suggest using an int array instead of a double, unless the task calls for it, which this one does not. +2
Christopher
6 May 2019, 03:17
The issue might be that your trying to figure this thing out by using arrays.
0