[URI Online Judge] – 1072 – Interval 2

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

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

Input

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

Output

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

Sample Input Sample Output
4
14
123
10
-25
2 in
2 out

Solution:

#include <iostream>
#include <cstdio>
using namespace std;
int main(){
 int c, n, i = 0, o = 0;
 cin >> c;
 while (c--){
 cin >> n;
 if (n > 9 && n < 21)
 i++;
 else
 o++;
 }
cout << i << " in" << endl;
 cout << o << " out" << endl;
 return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s