128k views
4 votes
When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. For this program, adjust the values by subtracting the smallest value from all the values. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers.Ex: If the input is 5 30 50 10 70 65, the output is:20 40 0 60 55For coding simplicity, follow every output value by a space, including the last one.

User Eshlox
by
5.6k points

1 Answer

3 votes

Answer:

class TestCode {

public static void main(String args[]) {

Scanner scanner = new Scanner(System.in);

int n = scanner.nextInt();

int arr[] = new int[n];

int min = Integer.MAX_VALUE;

for(int i = 0;i<n;i++){

arr[i] = scanner.nextInt();

if(min > arr[i]){

min = arr[i];

}

}

for(int i = 0;i<n;i++){

System.out.print((arr[i]-min) + " ");

}

}

}

User You Kim
by
5.7k points