A beginner in c ++ and even have no idea how to perform this function.
Closed due to the fact that off-topic participants mymedia , Abyx , andreymal , aleksandr barakin , Viktorov Dec 21 '17 at 5:29 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- " Learning tasks are allowed as questions only on the condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- mymedia, Abyx, andreymal, aleksandr barakin, Viktorov
- 3To execute a function is simple: SomeFunc (); and the function will be executed! - Vladimir Martyanov
- oneYou would still go to the page with the rules, how to ask a question on the forum, while loud laughter did not go on the Internet - Alexander Muksimov
|
2 answers
It all depends on what type of message you have. I will give an example for string:
void printSorted(std::string str); int main() { std::string str = "aba caba baba"; printSorted(str); } void printSorted(std::string str) { int i=0; int j=0; std::vector<std::string> to_sort; while (i<str.length()) { while (i<str.length() && str[i]==' ') { i++; continue;} if (i>=str.length()) {break;} j = i; while (i<str.length() && str[i]!=' ') i++; to_sort.push_back( str.substr(j, ij) ); i++; } std::sort(to_sort.begin(), to_sort.end()); for (std::string i : to_sort) std::cout<<i<<" "; } - void ABCOrder (char * s) And how, for example, if the function is given so? - Ray_G
- are you writing C or C ++? And for the future, read this, please . Ru. Stackoverflow.com/help/how-to-ask - koshachok
- C ++, thanks in advance - Ray_G
|
//нужны всего 4 строки кода #include <iostream> #include <set> #include <iterator> using namespace std; int main() { set<string> sms; typedef std::istream_iterator<std::string> I; copy( I(cin), I(), inserter(sms, sms.begin())); //тут вместо cin может быть любой входной поток for (string s : sms) cout << s <<'\n'; return 0; } |