Skip to content

Instantly share code, notes, and snippets.

@amoshyc
Created November 25, 2014 13:50
Show Gist options
  • Save amoshyc/a7eba1a395b061430bec to your computer and use it in GitHub Desktop.
Save amoshyc/a7eba1a395b061430bec to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char input[100][100 + 2];
int idx = 0;
int max_len = 0;
while (fgets(input[idx], 100+2, stdin) != NULL) {
int len = strlen(input[idx]);
if (input[idx][len-1] == '\n') {
input[idx][len-1] = '\0';
len--;
}
if (len > max_len)
max_len = len;
idx++;
}
const int N = idx;
int i, j;
for (i=0; i<max_len; i++) {
for (j=N-1; j>=0; j--) {
if (i >= strlen(input[j]))
printf(" ");
else
printf("%c", input[j][i]);
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment