You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
static void plusMinus(int[] arr) { double p=0,n=0,z=0; int al = arr.length; for(int i=0;i<al;i++) { if(arr[i]>0) { p++; } else if(arr[i]<0) { n++; } else if (arr[i]==0) { z++; } } System.out.printf("\n%1$.6f", p/al); System.out.printf("\n%1$.6f" ,n/al); System.out.printf("\n%1$.6f", z/al); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] arr = new int[n]; for(int arr_i = 0; arr_i < n; arr_i++){ arr[arr_i] = in.nextInt(); } plusMinus(arr); in.close(); }
} why this code is not being approved???
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
} why this code is not being approved???