反转字符串

2017-10-24  本文已影响5人  我是明明哥
cout << "Please Enter a word: ";
    string word;
    cin >> word;
    
    char temp;
    int i,j;
    for (int j = 0, i = word.size() - 1; j < i; ++j,--i) {
        temp = word[i];
        word[i] = word[j];
        word[j] = temp;
    }
    cout << word;
上一篇 下一篇

猜你喜欢

热点阅读