2022-12-04 16:10:53 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2022-12-05 23:41:45 +01:00
|
|
|
int numarr_to_int(char numarr[2], int tpos) {
|
|
|
|
//printf("- D: %i; %i -\n", numarr[0]-'0', numarr[1]-'0'); //DEBUG
|
|
|
|
if(tpos==0) { return (numarr[1] - '0'); }
|
|
|
|
else { return (( (numarr[1] - '0') * 10 ) + (numarr[0] - '0')); }
|
|
|
|
}
|
2022-12-04 16:10:53 +01:00
|
|
|
|
2022-12-05 23:41:45 +01:00
|
|
|
void clear_num_arr(char numarr[2]) {
|
|
|
|
numarr[0] = '0'; numarr[1] = '0';
|
2022-12-05 12:15:01 +01:00
|
|
|
}
|
|
|
|
|
2022-12-05 23:41:45 +01:00
|
|
|
int main() { //Hi. The input-file has to have an empty line at the end. Sorry.
|
2022-12-04 21:33:10 +01:00
|
|
|
FILE *input_file = fopen("./input.txt", "r");;
|
2022-12-04 16:10:53 +01:00
|
|
|
fseek(input_file, 0, SEEK_END);
|
|
|
|
int if_size = ftell(input_file);
|
|
|
|
fseek(input_file, 0, SEEK_SET);
|
|
|
|
char input[if_size];
|
2022-12-04 21:33:10 +01:00
|
|
|
char c[1];
|
|
|
|
int val_arr[4];
|
|
|
|
int pos = 0;
|
|
|
|
char tmp_num[2];
|
2022-12-05 23:41:45 +01:00
|
|
|
int tmp_pos = 1;
|
2022-12-04 21:33:10 +01:00
|
|
|
int fully = 0;
|
2022-12-05 23:41:45 +01:00
|
|
|
int at_all = 0;
|
2022-12-04 16:10:53 +01:00
|
|
|
|
|
|
|
do {
|
2022-12-05 12:15:01 +01:00
|
|
|
c[0] = fgetc(input_file);
|
2022-12-04 21:33:10 +01:00
|
|
|
|
2022-12-05 23:41:45 +01:00
|
|
|
if(c[0]=='-' || c[0]==',') {
|
|
|
|
val_arr[pos] = numarr_to_int(tmp_num, tmp_pos);
|
|
|
|
tmp_pos = 1;
|
|
|
|
clear_num_arr(tmp_num);
|
2022-12-04 21:33:10 +01:00
|
|
|
pos++;
|
2022-12-05 12:15:01 +01:00
|
|
|
continue;
|
2022-12-04 21:33:10 +01:00
|
|
|
}
|
2022-12-05 23:41:45 +01:00
|
|
|
if(c[0]=='\n' || c[0]=='\r') {
|
|
|
|
val_arr[pos] = numarr_to_int(tmp_num, tmp_pos);
|
|
|
|
tmp_pos = 1;
|
|
|
|
clear_num_arr(tmp_num);
|
2022-12-04 21:33:10 +01:00
|
|
|
pos = 0;
|
2022-12-05 23:41:45 +01:00
|
|
|
//printf("%i; %i; %i; %i\r\n", val_arr[0], val_arr[1], val_arr[2], val_arr[3]); //DEBUG
|
|
|
|
if((val_arr[0]>=val_arr[2] && val_arr[1]<=val_arr[3]) || (val_arr[2]>=val_arr[0] && val_arr[3]<=val_arr[1])) fully++;
|
|
|
|
if((val_arr[1]>=val_arr[2] && val_arr[0]<=val_arr[3]) || (val_arr[3]>=val_arr[0] && val_arr[2]<=val_arr[1])) at_all++;
|
2022-12-05 12:15:01 +01:00
|
|
|
continue;
|
2022-12-04 21:33:10 +01:00
|
|
|
}
|
2022-12-05 23:41:45 +01:00
|
|
|
|
2022-12-04 21:33:10 +01:00
|
|
|
tmp_num[tmp_pos] = c[0];
|
2022-12-05 23:41:45 +01:00
|
|
|
tmp_pos--;
|
2022-12-05 12:15:01 +01:00
|
|
|
}
|
|
|
|
while(c[0] != (char)-1);
|
2022-12-04 21:33:10 +01:00
|
|
|
|
|
|
|
printf("~UwU Twying c todayw, awwen't we master? *^w^* Hewe is youww wesult: UmU~ : %i\r\n", fully);
|
2022-12-05 23:41:45 +01:00
|
|
|
printf("!OwO WHat wAs thAt MAstaww?!?! You wouwd like additioneww infowmatiown?!: UmU~ : %i\r\n", at_all);
|
2022-12-04 16:10:53 +01:00
|
|
|
return 0;
|
2022-12-05 23:41:45 +01:00
|
|
|
}
|