读入一行不大于80个字符的字符串,逆序后输出。
#include <iostream>
using namespace std;
int main() {
char str[81], t, *p, *q;
cout << "Input a string:";
gets(str);
p = q = str;
while (*q)
q++;
q--;
while (p < q) {
t = *p;
*p = *q;
*q = t;
p++;
q--;
}
cout << str;
return 0;
}