Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Author: Nishant Sharma
- //HackerRank : Encryption
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include <map>
- #include <math.h>
- using namespace std;
- int main() {
- string strcall;
- cin >> strcall;
- double j = sqrt(strcall.length());
- int len = j;
- int col;
- j = len * len;
- if (j == strcall.length()) {
- col = len;
- } else {
- col = len + 1;
- while (col * len < strcall.length()) {
- len++;
- }
- }
- int index;
- for (int i = 0; i < col; i++) {
- for (int k = 0; k < len; k++) {
- index = (k*col) + (i);
- if(index<strcall.length())
- cout << strcall[index];
- }
- cout << " ";
- }
- }
Add Comment
Please, Sign In to add comment