Algorithm


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

Even Between five Numbers

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that reads five integer values. Count how many of these values ​​are even and  print this information like the following example.

Input

The input will be 5 integer values.

Output

Print a message like the following example with all letters in lowercase, indicating how many even numbers were typed.

Input Sample Output Sample

7
-5
6
-4
12

3 valores pares

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h<

int main()
{
    int a, i;
    int tmp = 0;

    for (i = 0; i  <  5; ++i)
    {
        scanf("%d", &a);
        if(a < 0) {
            a = -a;
        }

        if(a % 2 == 0) {
            tmp++;
        }
    }

    printf("%d valores paresn", tmp>;

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

Input

x
+
cmd
7 -5 6 -4 12

Output

x
+
cmd
3 valores pares

#2 Code Example with C++ Programming

Code - C++ Programming


#include <cstdio>

int main()
{
    int a;
    int tmp = 0;

    for (int i = 0; i  <  5; ++i)
    {
        scanf("%i", &a);
        if(a < 0) {
            a = -a;
        }

        if(a % 2 == 0) {
            tmp++;
        }
    }

    printf("%i valores paresn", tmp>;

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

Input

x
+
cmd
7 -5 6 -4 12

Output

x
+
cmd
3 valores pares

#3 Code Example with Java Programming

Code - Java Programming


import java.util.*;

public class Main {
    public static void main(String args[]) {
        int a, i;
        int tmp = 0;
        Scanner input = new Scanner(System.in);
        for (i = 0; i  <  5; ++i)
        {
            a = input.nextInt();
            if(a < 0){
                a = -a;
            }

            if(a % 2 == 0){
                tmp++;
            }
        }

        System.out.printf("%d valores paresn", tmp>;
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
7 -5 6 -4 12

Output

x
+
cmd
3 valores pares

#4 Code Example with Python Programming

Code - Python Programming


count=0
for i in range(5):
    n = float(input())
    if(n%2==0):
        count=count+1
print(f"{count} valores pares")
Copy The Code & Try With Live Editor

Input

x
+
cmd
7 -5 6 -4 12

Output

x
+
cmd
3 valores pares
Advertisements

Demonstration


Previous
#1064 Beecrowd Online Judge Solution 1064 Positives and Average - Solution in C, C++, Java, Python and C#
Next
#1066 Beecrowd Online Judge Solution 1066 Even, Odd, Positive and Negative - Solution in C, C++, Java, Python and C#