fork download
  1. #include <iostream>
  2. #include <list>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. bool compare(string a, string b) {
  7. cout << a.front() << " " << b.front() << endl;
  8. return(a.front() == b.front());
  9. }
  10. void Fifth_task(list <string>& lst) {
  11. list <string> ::iterator it;
  12. lst.sort();
  13. lst.unique(compare);
  14. for (it = lst.begin(); it != lst.end(); ++it) {
  15. cout << *it << endl;
  16. }
  17. }
  18.  
  19.  
  20. int main(){
  21. list <string> first;
  22. first.push_back("Hello");
  23. first.push_back("Johnny");
  24. first.push_back("Hello");
  25. first.push_back("Ildar");
  26. Fifth_task(first);
  27. return 0;
  28. }
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
H  H
H  I
I  J
Hello
Ildar
Johnny