fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string str1 = "WATER";
  7. string str2 = "PRINGLE";
  8.  
  9. int N = (int) (str2.length()/(double)str1.length() + 1);
  10.  
  11. string temp = "";
  12. for (int i=0; i<N; i++)
  13. temp += str1;
  14.  
  15. string result = temp.substr(0, str2.length());
  16. cout << result << endl;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
WATERWA