URI / BEE CROWD 1072 - Interval 2 Solution in C,C++,Python | URI - BEECROWD - BEE 1072 Solution

URI / BEE CROWD 1072 - Interval 2 Solution in C,C++,Python | URI - BEECROWD - BEE 1072 Solution in C,C++,Python

 beecrowd | 1072

Interval 2

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N. This N will be the number of integer numbers that will be read.  

Print how many these numbers are in the interval [10,20] and how many values are out of this interval.

Input

The first line of input is an integer (< 10000), that indicates the total number of test cases.
Each case is an integer number (-107 < X < 107).

 

Output

For each test case, print how many numbers are in and how many values are out of the interval.

Input SampleOutput Sample

4
14
123
10
-25

2 in
2 out

URI / BEE CROWD 1072 - Interval 2 Solution in C,C++,Python | URI - BEECROWD - BEE 1072 Solution in C,C++,Python

                                        Demonstration:

What is Interval?
An interval is a range of numbers between two given numbers and includes all of the real numbers between those two numbers.
For example, the set of numbers x satisfying 0 ≤ x ≤ 5 is an interval that contains 0, 5, and all numbers between 0 and 5.
Here we apply a range-based for loop which will run between two numbers and checking the condition for finding the numbers of an interval such as [10,20] which are applied and printing the numbers. 
N.B: Don't copy paste the code as same. Just try to understand it and try yourself.

  URI / BEE 1072 Solution in C :   

  URI / BEECROWD Online Judge 1072 Solve  in C :                                          

#include <stdio.h>
int main()
{
    int x, a, i;

    int in = 0;
    int out = 0;

    scanf("%d", &x);
    for(i = 0; i < x; i++)
    {
        scanf("%d", &a);
        if(a >= 10 && a <= 20){
            in++;
        }else{
            out++;
        }

    }
    printf("%d in\n", in);
    printf("%d out\n", out);

    return 0;
}

 

1 Response to URI / BEE CROWD 1072 - Interval 2 Solution in C,C++,Python | URI - BEECROWD - BEE 1072 Solution