Skip to content

Instantly share code, notes, and snippets.

@koluku
Created November 18, 2016 08:20
Show Gist options
  • Save koluku/c645151f32032b745ee1d95f290196cd to your computer and use it in GitHub Desktop.
Save koluku/c645151f32032b745ee1d95f290196cd to your computer and use it in GitHub Desktop.
/*
* Exercise 8-2a, shiritori.c
*/
#include <stdio.h>
#include <string.h>
int main(void){
int i = 0;
char a[17], b[17];
scanf("%s", a);
scanf("%s", b);
if(a[strlen(a)-1] == b[0]) {
i += 1;
}
if(b[strlen(b)-1] == a[0]) {
i += 2;
}
if(i == 0) {
printf("NG\n");
}
else if(i == 1) {
printf("%s\n%s\n", a, b);
}
else if(i == 2) {
printf("%s\n%s\n", b, a);
}
else if(i == 3){
printf("Any order\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment