rendered paste body#include <stdio.h>
int check_baby (char*, char*, char*);
int main() {
FILE *fp;
fp = fopen("s1.in", "r");
char mother[11], father[11], baby[6];
int num_babies = 0;
fscanf(fp, "%s", mother);
fscanf(fp, "%s", father);
fscanf(fp, "%d", &num_babies);
int x;
for (x = 1; x <= num_babies; x++) {
fscanf(fp, "%s", baby);
if (check_baby(mother, father, baby))
printf("Possible baby.\n");
else
printf("Not their baby!\n");
}
fclose(fp);
printf("\n\n");
system("pause");
return 0;
}
int check_baby(char *mother, char *father, char *baby) {
int correct = 0;
/* inherited from */
char *infr;
int x;
for (x = 0; x < 5; x++) {
if (mother[x*2] + mother[x*2+1] < father[x*2] + father[x*2+1])
infr = &mother[x*2];
else
infr = &father[x*2];
if (infr[0] == baby[x] || infr[1] == baby[x])
correct++;
}
return (correct == 5 ? 1 : 0);
}