Algorithm


Problem Name: beecrowd | 1060
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1060

Positive Numbers

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads 6 numbers. These numbers will only be positive or negative (disregard null values). Print the total number of positive numbers.

Input

Six numbers, positive and/or negative.

Output

Print a message with the total number of positive numbers.

Input Sample Output Sample

7
-5
6
-3.4
4.6
12

4 valores positivos

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>
int main()
{
    double n;
    int tmp = 0, i;

    for (i = 0; i  <  6; ++i)
    {
        scanf("%lf", &n);
        if(n > 0){
        tmp++;
        }
    }

    printf("%i valores positivosn", tmp);

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
7 -5 6 -3.4 4.6 12

Output

x
+
cmd
4 valores positivos

#3 Code Example with Java Programming

Code - Java Programming


import java.util.*;

public class Main {
    public static void main(String args[]) {
        double n;
        int tmp = 0, i;
        Scanner sc = new Scanner(System.in);
        
        for (i = 0; i  <  6; ++i)
        {
            n = sc.nextDouble();
            if(n > 0){
                tmp++;
            }
        }
            
        System.out.printf("%d valores positivosn", tmp);
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
7 -5 6 -3.4 4.6 12

Output

x
+
cmd
4 valores positivos

#4 Code Example with Python Programming

Code - Python Programming


count = 0
for i in range(6):
    nums = float(input())
    if(nums>0):
       count+=1
print(f'{count} valores positivos')
Copy The Code & Try With Live Editor

Input

x
+
cmd
7 -5 6 -3.4 4.6 12

Output

x
+
cmd
4 valores positivos
Advertisements

Demonstration


Previous
#1059 Beecrowd Online Judge Solution 1059 Even Numbers- Solution in C, C++, Java, Python and C#
Next
#1061 Beecrowd Online Judge Solution 1061 Event Time - Solution in C, C++, Java, Python and C#