Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Thanks, I', really into your katas! I hope that they will allow me to be better at programming, since I'm a total novice. Greetings.

  • Custom User Avatar

    So yeah, that's my code. When I run it on cpp.sh with a sample test string (std::string strng = "abcd\nEFGH\nijkl\nMNOP";) and replace k and n with constant numbers (just because these parameters aren't passed to any function), I get exactly the expected output.

    class ScalingSqStrings
    {
    public:
        static std::string scale(const std::string &strng, int k, int n)
        {if(strng == "") return "";
        std::string temp="";
    
       for(int i=0; i<strng.length(); i++)
          {
            
            for(int j=0; j<k; j++)
                
            {
            
            if(strng[i] == '\0' || strng[i] == '\n' ){
                
                for(int l=0; l<n; l++)
                {
                   std::cout << temp << "\n"; 
                }
                temp="";
                break;
                
            }
            temp+=strng[i];
            }
            
            //if(strng[i] == '\n') std::cout << '\n';
            
           }
            for(int l=0; l<n; l++)
                {
                   std::cout << temp << "\n"; 
                }
          }
    };
    
  • Custom User Avatar

    My code displays the correct output in other compilers (for example c++ shell), but somehow I'm not able to get it working here. How can I solve it?