72 lines
1.2 KiB
C
Raw Permalink Normal View History

2023-12-01 13:35:13 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 2100
int isAlpha(char c) {
if (c >= 'a' && c <= 'z') {
return 1;
}
if (c >= 'A' && c <= 'Z') {
return 1;
}
return 0;
}
void printBefore(char first[MAX], char second[MAX]) {
for (int i=0; i<strlen(first); i++) {
if (first[i] == '|') {
break;
}
if (isAlpha(first[i])) {
printf("%c", first[i]);
}
}
for (int i=0; i<strlen(second); i++) {
if (second[i] == '|') {
break;
}
if (isAlpha(second[i])) {
printf("%c", second[i]);
}
}
printf(" ");
}
void printAfter(char first[MAX], char second[MAX]) {
int pipeFound = 0;
for (int i=0; i<strlen(first); i++) {
if (pipeFound && isAlpha(first[i])) {
printf("%c", first[i]);
}
if (first[i] == '|') {
pipeFound = 1;
}
}
pipeFound = 0;
for (int i=0; i<strlen(second); i++) {
if (pipeFound && isAlpha(second[i])) {
printf("%c", second[i]);
}
if (second[i] == '|') {
pipeFound = 1;
}
}
printf("\n");
}
int main(int argc, char **argv) {
char first[MAX];
char second[MAX];
scanf("%s %s", first, second);
printBefore(first, second);
printAfter(first, second);
return 0;
}