<pre name="code" class="cpp">// 反向输出字符串 #include<iostream> #include<string.h> using namespace std; void f(char p[]); int main() { char s[50]; cout<<"请输入一个字符串: "; cin>>s; f(s); cout<<"反向输出的字符串为: "<<s<<endl; } void f(char p[]) { int n=strlen(p); for(int i=0;i<(n/2);i++) { char t=p[i]; p[i]=p[n-i-1]; p[n-i-1]=t; } }
原文地址:http://blog.csdn.net/doudouwa1234/article/details/45629087