2009年7月21日 星期二

Palindrome (c++)



#include <iostream>
#include <string>
using namespace std;

int main(void){
string s = "abcdef";
string::iterator pos;
reverse(s.begin(), s.end());

string tmp ="";
for(int i=0; i< s.length(); i++){
tmp += s[s.length()-i-1];
}

for(pos = s.begin(); pos != s.end(); ++pos)
cout<<*pos;
cout<<endl;

cout<<s<<endl;
cout<<tmp<<endl;
return 0;
}

沒有留言:

張貼留言