fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. std::string interleave(const std::string &s1, const std::string &s2) {
  5. int length = std::min(s1.length(), s2.length());
  6. std::string result;
  7. for (int i = 0; i < length; i++) {
  8. result += s1[i];
  9. result += s2[i];
  10. }
  11. return result;
  12. }
  13.  
  14. int main() {
  15. std::cout << interleave("aaaaaa", "drzewko") << std::endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
adarazaeawak