Created
January 2, 2013 12:18
-
-
Save Abreto/4434182 to your computer and use it in GitHub Desktop.
UVa 490 - Rotating Sentences.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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