Sort by

recency

|

3229 Discussions

|

  • + 0 comments

    I absolutely love this theme idea — it looks stunning and very appealing! I’m planning to use it for my ecommerce-based store, mens compression socks, which is hosted on Shopify

  • + 0 comments

    javascript print negative first positive ?

    negativeRatio positiveRatio zeroRatio

  • + 1 comment

    def plusMinus(arr): n=len(arr) count_p=0 count_neg=0 count_zero=0 for i in arr: if i>0: count_p+=1 elif i<0: count_neg+=1 elif i==0: count_zero+=1 print(count_p/n) print(round(count_neg/n,6)) print(round(count_zero/n,6))

  • + 0 comments

    No need to set the amount of decimals, it recognises the answers without needing the precise decimal point

    void plusMinus(vector<int> arr) {
        
        int maxNumber = arr.size();
        float zeroCount {0.0f};
        float posCount {0.0f};
        float negCount {0.0f}; 
        
        for(int i = 0; i < maxNumber; i++)
        {
            if (arr[i] == 0 )
            {
                
                zeroCount++;
                
            }    
            if (arr[i] > 0)
            {
                
                posCount++;
                
            }
            else if (arr[i] < 0)
            {
                
               negCount++; 
                
            }
            
        }
        
            std::cout << posCount/maxNumber << std::endl;
            std::cout << negCount/maxNumber << std::endl;
            std::cout << zeroCount/maxNumber << std::endl;
            
    }
    
  • + 0 comments

    Java 7 Solution

    double postiveNum=0,negativeNum=0;

        for(int x : arr)
        {
            if(x>0)
              postiveNum++;
            else if(x<0)
              negativeNum++;
    
        }
        System.out.printf("%.6f\n",(postiveNum/arr.size()));
        System.out.printf("%.6f\n",(negativeNum/arr.size()));
        System.out.printf("%.6f\n",((arr.size()-(postiveNum+negativeNum))/arr.size()));