Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C/C++·的翻转文字列 #6

Open
xinxin0430 opened this issue Dec 22, 2017 · 2 comments
Open

C/C++·的翻转文字列 #6

xinxin0430 opened this issue Dec 22, 2017 · 2 comments

Comments

@xinxin0430
Copy link

xinxin0430 commented Dec 22, 2017

#include<iostream>
#include<string>
using namespace std;

int main()
{
	string str("");
	string newStr("");
	cout << "input your message :";
	cin >> str;
	for (int i = (str.length() - 1); i >= 0; i--) {
		newStr += str[i];
	}
	cout << newStr << endl;
	cin.ignore(6);
}
@ismdeep
Copy link

ismdeep commented Aug 22, 2020

啊这~贴代码尽量用上 ``` 格式来标注代码例如:

#include <iostream>
#include <string>
using namespace std;

string reverse(string str) {
    string newStr;
    for (int i = str.length() - 1; i >= 0; --i) {
        newStr += str[i];
    }
    return newStr;
}

int main()
{
    string str;
    cout << "input your message :";
    cin >> str;
    cout << reverse(str) << endl;
    return 0;
}

@xinxin0430
Copy link
Author

啊这~贴代码尽量用上 ``` 格式来标注代码例如:

#include <iostream>
#include <string>
using namespace std;

string reverse(string str) {
    string newStr;
    for (int i = str.length() - 1; i >= 0; --i) {
        newStr += str[i];
    }
    return newStr;
}

int main()
{
    string str;
    cout << "input your message :";
    cin >> str;
    cout << reverse(str) << endl;
    return 0;
}

好的,谢谢,现在加上了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants