URI / BEE CROWD 1072 - Interval 2 Solution in C,C++,Python | URI - BEECROWD - BEE 1072 Solution in C,C++,Python
Interval 2
Adapted by Neilor Tonin, URI Brazil
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 an 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.
Input Sample | Output Sample |
4 | 2 in |
URI / BEE CROWD 1072 - Interval 2 Solution in C,C++,Python | URI - BEECROWD - BEE 1072 Solution in C,C++,Python
Demonstration:
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;
}
Good
ReplyDelete