逆反字符串
求问大佬这段代码啥意思啊??题目奉上:
输入:#
ldrow
olleh
#
输出:world
holle
#include<stdio.h>
#include<stdlib.h>
int main()
{
char c;
int i, j, k, b1;
char a[100];
char b[100];
c = getchar();
while (c == '#')
{
getchar(); //收回车
b1 = 0;
if ((c = getchar()) == '#') break; //如果是# 退出循环
else
{
a[0] = c; i = 0; j = 0; //设置i,j为单词起始,结尾
for (k = 1; (c = getchar()) != '#'; k++)
{
a[k] = c;
if (c == ' ' || c == '\n')
{
j = k - 1; //a[k]==' '||'\n' a[j]=a[k-1]为单词结尾
for (; j >= i; j--, b1++)
{
b[b1] = a[j];
}
b[b1] = c;
b1++;
i = k + 1; //k+1为下一单词开头
}
}
}
for (b1 = 0; b1 < i - 1; b1++)
printf("%c", b[b1]);
printf("\n");
getchar(); //收回车
c = getchar();
}
return 0;
}