View Code of Problem 114

#include <stdio.h>
#include <string.h>

int main(void)
{
    char str[1000];
    while(gets(str) != NULL)
    {
        int m,i,j = 0,k = 0;
        char s[100][1000];
        for(i = 0; i < strlen(str);i++)
        {
            if(str[i] != ' ' && i != strlen(str))
            {
                s[j][k++] = str[i];
            }
            if(str[i] == ' ')
            {
                s[j++][k] = '\0';
                k = 0;
            }
            if(i == strlen(str))
            {
                s[j][k++] = str[i];
                s[j++][k] = '\0';
                k = 0;
            }
        }
        for(i = 0;i <= j;i++)
        {
            for(k = strlen(s[i]) - 1;k > -1;k--)
                printf("%c",s[i][k]);
            printf(" ");
        }
        printf("\n");
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 114