• + 0 comments

    C++

    string encryption(string s) {
        string res = "";
        int col = ceil(sqrt(s.length()));
        for (int c = 0; c < col; c++) {
            for (int i = c; i < s.length(); i+=col) {
                res.append(1,s[i]);
            }
            res.append(" ");
        }
        return res;
    }