输入字符串反序输出

#include<stdio.h>
#include<string.h>
int main()
{
	char str[100],ch;
	int i,j,k;
	printf("please input a string:\n");
	scanf("%s",&str);
	k = strlen(str);
	for(i=0,j=k-1;i<k/2;i++,j--)
	{
		ch = str[i];
		str[i] = str[j];
		str[j] = ch;
	}
	printf("%s\n",str);
	return 0;
}
please input a string:
HelloWorld
dlroWolleH
Press any key to continue


posted @ 2017-07-03 13:09  cxchanpin  阅读(484)  评论(0编辑  收藏  举报