Skip to content

Commit 852a863

Browse files
authored
Create Encryption
1 parent cdd1048 commit 852a863

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Encryption

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//https://www.hackerrank.com/challenges/encryption/problem
2+
#include <bits/stdc++.h>
3+
4+
using namespace std;
5+
6+
int main()
7+
{
8+
string s;
9+
cin >> s;
10+
int n = s.size();
11+
int row = round(sqrt(n));
12+
int col;
13+
if (row >= sqrt(n))
14+
col = row;
15+
else
16+
col = row + 1;
17+
for(int j=0;j<col;++j)
18+
{
19+
for(int i=j; i<n;i+=col)
20+
cout << s[i];
21+
cout << ' ';
22+
}
23+
return 0;
24+
}

0 commit comments

Comments
 (0)