Wednesday, December 2, 2015

Uri problem 1072 solve

Problem :

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 a 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.
Sample InputSample Output
4
14
123
10
-25
2 in
2 out

Solution:

#include<stdio.h>
int main()
{
  long long T, x, in=0, out=0;
  scanf("%lld",&T);
  while(T--){
    scanf("%lld",&x);
    if(x>=10 && x<=20)
        in++;
    else
        out++;
  }
  printf("%lld in\n%lld out\n",in,out);
    return 0;
}

No comments:

Post a Comment