String形式
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>
using namespace std;
int main () {
string str;
cout<<"Enter a line of text:";
cin>>str;
reverse(str.begin(),str.end());
cout<<str<<endl;
system("PAUSE");
return 0;
}
字元陣列型式
#include <stdlib.h>
#include <iostream.h>
#include <string.h>
int main()
{
char s[]="abcd";
strrev(s);
cout<<s;
system("PAUSE");
return 0;
}
沒有留言:
張貼留言