/*字符串的反转===字符的交换
用第一个字符和最后一个字符交换,第二个字符和倒数第二个交换
*/
#include <iostream>
using namespace std;
int main() {
char b[100];
char *str=b,*i,*j;
int len=0;
char a,temp;
while (cin >> a)
{
*(str++) = a;
len++;
}
for (int k = 0; k < len; k++)
cout << b[k] << " ";
//用指针的方法交换位置
for (i = b, j = b + len-1; i < j; i++, j--)
{
temp = *i;
*i = *j;
*j = temp;
}
//用数组的方法交换位置
int n, m;
for (m = 0, n = len - 1; m < n; m++, n--)
{
temp = b[m];
b[m] = b[n];
b[n] = temp;
}
cout << endl;
for (int k = 0; k < len; k++)
cout <<b[k]<< " ";
return 0;
}