标签:ret for argv etl pause def har lin 字符串逆序
#include <iostream> #include <string> #define MAX_STR_LEN 1024 using namespace std; int main(int argc, char * argv[]) { #if 0 // 使用自带的方法进行逆序操作 string str; cin >> str; str.assign(str.rbegin(), str.rend()); reverse(str.begin(), str.end()); cout << str << endl; #endif // 使用自定义的方法进行逆序操作 char a[MAX_STR_LEN] = { ‘\0‘ }; cin.getline(a, MAX_STR_LEN, ‘\n‘); size_t i, j; for (i = 0, j = strlen(a) - 1; i < strlen(a) / 2; i++, j--) { char temp; temp = a[i]; a[i] = a[j]; a[j] = temp; } cout << a << endl; system("pause"); return 0; }
标签:ret for argv etl pause def har lin 字符串逆序
原文地址:http://www.cnblogs.com/lsgxeva/p/7945712.html