反转字符串

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;
0 0 vote
Article Rating
Subscribe
提醒
guest
0 评论
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x