Skip to content

Instantly share code, notes, and snippets.

@Abreto
Created January 2, 2013 12:18
Show Gist options
  • Save Abreto/4434182 to your computer and use it in GitHub Desktop.
Save Abreto/4434182 to your computer and use it in GitHub Desktop.
UVa 490 - Rotating Sentences.
/* UVa 490 - Rotating Sentences. */
#include <stdio.h>
#include <string.h>
int main()
{
int i = 0, j = 0;
int N = 0;
char sentences[100][100];
int length[100] = {0};
int maxlength = 0;
while(gets(sentences[N]))
{
length[N] = strlen(sentences[N]);
if( length[N] > maxlength ) maxlength = length[N];
N++;
}
for(i = 0;i < maxlength;i++)
{
for(j = N;j > 0;j--)
if(i >= length[j-1])
printf(" ");
else
printf("%c", sentences[j-1][i]);
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment