Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
564 B
1
Indexable
Never
#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;
            }
        }
    }
}