C++ (main.cpp):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <iostream> #include <cstdlib> #include <cstring> using namespace std; int main( void ) { char str[99]; int i; while (cin.getline(str, 99, '\n' )) { for (i= strlen (str)-1;i>=0;i--) { cout << str[i]; } cout << endl; } return 0; } |
範例結果:
說明:
基礎連續字串反轉範例。