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

 

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



[Solution in C++]:

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;

    long long int in=0, out=0;

    long long arr[n];
    for(int i=0; i<n; i++){
        cin>>arr[i];
        if(arr[i]>=10 && arr[i]<=20){
            in++;
        }else{
            out++;
        }
   
    }
    cout<<in<<" in"<<endl;
    cout<<out<<" out"<<endl;

    return 0;
}

Comments

Anonymous said…
java ??

Popular posts from this blog

Whiteboarding Interviews

Version Control with Git: A Beginner’s Guide

Callback function in JavaScript