Sort by

recency

|

3195 Discussions

|

  • + 0 comments

    Plus Minus has its pros and cons, but when it comes to reliable service, you always want the best. If you're looking for expert plumbing contractors Philadelphia, make sure to choose a team that knows the ins and outs of the job. A good plumber can save you from big headaches down the road! Who do you trust for plumbing work in Philly?

  • + 0 comments

    Language: JAVA 15

    In this problem We have to print the ratios of positive, negative and zero values with 6 digits after the decimal. To solve this problem I used printf() with format specifier

        public static void plusMinus(List<Integer> arr) {
        
        double positive=0;
        double negative=0;
        double zero=0;
    
        for(int i : arr){
            if(i>0){
                positive++;
            }
            else if(i<0){
                negative++;
            }
            else {
                zero++;
            }
            
        }
        
        System.out.printf("%.6f", positive/arr.size());
        System.out.println();
        System.out.printf("%.6f", negative/arr.size());
        System.out.println();
        System.out.printf("%.6f", zero/arr.size());
        
        }
    
  • + 0 comments
        public static void plusMinus(List<int> arr)
        {
            int p = 0, n = 0, z = 0, l = arr.Count;
            foreach(int el in arr)
            {
                if(el > 0)
                    p++;
                else if(el < 0)
                    n++;
                else if(el == 0)
                    z++;
            };
            
            decimal pD = p, nD = n, zD = z;
            
            Console.WriteLine((pD/l).ToString("F6"));
            Console.WriteLine((nD/l).ToString("F6"));
            Console.WriteLine((zD/l).ToString("F6"));
        }
    
  • + 0 comments

    ///Java Solution

    class Result { public static void plusMinus(List arr) { double countpos=0, countneg=0, countzero=0; double n=arr.size(); for(int i=0;i 0){ countpos++; } else if(arr.get(i) < 0){ countneg++; } else if(arr.get(i)==0){ countzero++; } }

     System.out.println(String.format("%.6f", countpos/n));
     System.out.println(String.format("%.6f", countneg/n));
     System.out.println(String.format("%.6f", countzero/n));
    
    }
    

    }

  • + 1 comment

    n = int(input().strip()) arr = [1 if int(temp)>0 else -1 if int(temp)<0 else 0 for temp in input().strip().split(' ') ] print("{0:.6f}".format(arr.count(1)/n)) print("{0:.6f}".format(arr.count(-1)/n)) print("{0:.6f}".format(arr.count(0)/n))