Pošalji i proveri. 

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main() {
	int x,y,i = 0,z = 0;
	char a[2];
	scanf("%c%c",&a[0],&a[1]);
	scanf("%d %d",&x,&y);
	i = x + y;
	if ((abs(x-y)) > 1) { printf("nemoguce"); return 1; }
	if ((x+y)%2==0) {while (z!=i) {
		printf ("%c%c",a[0],a[1]);
		z+=2;
	}}
	else if (x > y) {
		while (z!=(i-1)) {
			printf("%c%c",a[0],a[1]);
			z+=2;
		}
		printf("%c",a[0]);
	}
		else { while (z!=(i-1)) {
			printf("%c%c",a[1],a[0]);
			z+=2;
		}
		printf("%c",a[1]);
		}
    return 0;
}