#include <stdio.h>
#include <string.h>
int main(int argc, const char *argv[])
{
char a[50]="this is a book";
int i=0,j=0,temp;
int spaceindex=0;
while(a[i]!='\0')
{
i++;
}
j=i-1;
i=0;
while(i<j)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
i++;
j--;
}
i=0;
j=0;
while(a[spaceindex]!='\0')
{
i=spaceindex;
j=spaceindex;
while(a[i]==' ')
{
i++;
j=i;
}
while(a[j]!=' '&&a[j]!='\0')
{
j++;
}
spaceindex=j;
j--;
while(i<j)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
i++;
j--;
}
}
puts(a);
return 0;
}
this is a book --->book a is this