26.03.2013, 21:58
Quote:
Hasta ahorita lei que era por palabras (yo pensaba que era por letras) y en forma vertical, si es vertical puede ser un poco mбs complicado.
|
Pues asн serб:
pawn Код:
#include <stdio.h>
#include <stdlib.h>
#define MAX_WORDS ( 25 )
#define MAX_LENGHT ( 30 )
int main(int argc, char *argv[])
{
int
count = 0,
j = -1;
char c,
words[2][MAX_WORDS][MAX_LENGHT] = {{{'\0'}, {'\0'}}, {{'\0'}, {'\0'}}};
do
{
c = getchar();
if(c == ' ' || c == '\t' || c == EOF) count++, j = -1;
else if(count == MAX_WORDS) {printf("La cantidad maxima de palabras son %d.",MAX_WORDS); break;}
else if(c != '\n')words[0][count][++j] = c, words[1][count][j] = '|';
}
while( c != '\n');
printf("\n");
for(int i = MAX_LENGHT-1; i > -1; --i)
{
printf("%2d |", i+1);
for(int n = 0; n < MAX_WORDS; n++)
{
if(words[0][n][i] != '\0') printf("* ");
else printf(" ");
}
printf("\n");
}
printf(" +");
for(int i = 0; i < MAX_WORDS; i++) printf("---");
printf(" ");
for(int i = 0; i < MAX_WORDS; i++) printf("%2d ", i+1);
printf("\n");
system("pause");
return EXIT_SUCCESS;
}