-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1520.c
47 lines (36 loc) · 930 Bytes
/
1520.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <string.h>
#define TRUE 1
#define FALSE 0
char readInput(int *num);
int main()
{
int total_count;
int ranges[101];
int start, end, i, j, query, total_in_range;
while (readInput(&query) != EOF)
{
memset(ranges, 0, sizeof(ranges));
for (j = 0; j < query; j++)
{
scanf("%d %d", &start, &end);
for (i = start; i <= end; i++)
++ranges[i];
}
total_count = 0;
scanf("%d", &j);
if (ranges[j])
{
for (i = 1; i < j; i++)
total_count += ranges[i];
printf("%d found from %d to %d\n", j, total_count, (total_count + ranges[j] - 1));
}
else
printf("%d not found\n", j);
}
return 0;
}
char readInput(int *num)
{
return scanf("%d", num) == 1 ? TRUE : EOF;
}