-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathencryption.cpp
More file actions
50 lines (48 loc) · 994 Bytes
/
encryption.cpp
File metadata and controls
50 lines (48 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
string s;
getline(cin,s);
s.erase(remove_if(s.begin(), s.end(),::isspace ),s.end());
int len=s.size();
int low=floor(sqrt(len));
int high=ceil(sqrt(len));
if(low*high<=len)
{
low=high;
}x
vector<vector<char>> charMatrix(low,vector<char>(high));
for(int i=0;i<high;i++)
{
for(int j=0;j<low;j++)
{
int index=j*high+i;
if(index>=len)
{
charMatrix[j][i]='*';
}
else
{
charMatrix[j][i]=s[index];
}
}
}
for(int i=0;i<high;i++)
{
for(int j=0;j<low;j++)
{
if(charMatrix[j][i]!='*')
cout<<charMatrix[j][i];
else
continue;
}
cout<<" ";
}
return 0;
}