单词逆序输出 字符串 c语言,字符串中的每个单词倒序输出问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#include

void sub_reverse(char *);

int main()

{

char str[256] = "The only way to learn a new programming language is by writing programs in it";

char string[256] = "Oh,My god!What are you doing here? \"Come boy!\"";

printf("%s\n",str);

sub_reverse(str);

printf("%s\n",str);

printf("%s\n",string);

sub_reverse(string);

printf("%s\n",string);

return 0;

}

void sub_reverse(char *s)

{

char *pfstchr;

char *plstchr;

char *head;

char *end;

char tmp;

pfstchr = s;

while(*pfstchr!='\0')

{

if(*pfstchr==0x20||*pfstchr==','||*pfstchr=='.'||*pfstchr=='?'||*pfstchr=='!'||*pfstchr==';')

{

*pfstchr++;

}

else

{

plstchr = pfstchr + 1;

while(*plstchr!=0x20&&*plstchr!=','&&*plstchr!='.'&&*plstchr!='?'&&*plstchr!='!'&&*plstchr!=';'&&*plstchr!='\0')

{

plstchr++;

}

head = pfstchr;

end = plstchr - 1;

while(head

{

tmp = *head;

*head = *end;

*end = tmp;

head++;

end--;

}

pfstchr = plstchr;

}

}

}

The only way to learn a new programming language is by writing programs in it

ehT ylno yaw ot nrael a wen gnimmargorp egaugnal si yb gnitirw smargorp ni ti

Oh,My god!What are you doing here? "Come boy!"

hO,yM dog!tahW era uoy gniod ereh? emoC" yob!"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值