Untitled
unknown
plain_text
2 years ago
564 B
7
Indexable
#define ALPH_SIZE 26
const string alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int cat_index(int index) {
while (index > ALPH_SIZE) {
index = index - ALPH_SIZE;
}
return index;
}
void shift_massage(string& message, int shift) {
for (int i = 0; i < message.size(); i++) {
for (int j = 0; j < alf.size(); j++) {
if (message[i] == alf[j]) {
int index = cat_index(j + shift + i);
cout << index << endl;
message[i] = alf[index];
break;
}
}
}
}Editor is loading...