美文网首页
反转字符串

反转字符串

作者: 我是明明哥 | 来源:发表于2017-10-24 11:29 被阅读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;
    

    相关文章

      网友评论

          本文标题:反转字符串

          本文链接:https://www.haomeiwen.com/subject/klytpxtx.html