add exercise 4
This commit is contained in:
parent
bb38310111
commit
3ca002f252
2 changed files with 30 additions and 0 deletions
15
04.c
Normal file
15
04.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main () {
|
||||
int sum = 0;
|
||||
unsigned int p1,p2,r1,r2 = 0;
|
||||
|
||||
while (scanf("%u-%u,%u-%u\n", &p1,&p2,&r1,&r2) != EOF) {
|
||||
if (((p1 <= r1) && (p2 >= r2)) || ((p1 >= r1) && (p2 <= r2)))
|
||||
sum +=1;
|
||||
}
|
||||
printf("%d\n", sum);
|
||||
|
||||
}
|
15
04_02.c
Normal file
15
04_02.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main () {
|
||||
int sum = 0;
|
||||
unsigned int p1,p2,r1,r2 = 0;
|
||||
|
||||
while (scanf("%u-%u,%u-%u\n", &p1,&p2,&r1,&r2) != EOF) {
|
||||
if (((p1 <= r1) && (r1 <= p2)) || ((p1 <= r2) && (r2 <= p2)) || (r1 <= p1) && (p1 <= r2) || (r1 <= p2) && (p2 <= r2))
|
||||
sum +=1;
|
||||
}
|
||||
printf("%d\n", sum);
|
||||
|
||||
}
|
Loading…
Reference in a new issue