Untitled
unknown
plain_text
3 years ago
821 B
5
Indexable
#include <bits/stdc++.h>
using namespace std;
ifstream fin("criptare1.in");
ofstream fout("criptare1.out");
char m[205][25];
string mesaj, cheie;
pair<char, int> v[25];
int d_grupa, k;
int main(){
getline(fin, mesaj);
getline(fin, cheie);
for(int i=0; i<cheie.size(); i++){
v[i].first=cheie[i];
v[i].second=i;
}
sort(v, v+cheie.size());
d_grupa=mesaj.size()/cheie.size();
for(int i=0; i<cheie.size(); i++){
for(int j=1; j<=d_grupa; j++){
m[j][v[i].second+1]=mesaj[k];
k++;
}
}
for(int i=1; i<=d_grupa; i++){
for(int j=1; j<=cheie.size(); j++){
if(m[i][j]=='*'){
fout<<" ";
}
else{
fout<<m[i][j];
}
}
}
return 0;
}
Editor is loading...