EDIT: I had misunderstood the question, the following examples are wrong.
Here are 3 examples of C function (not tested) to change an upper case letter to another upper case letter.
c0 is the current character, c1 is the previuos character.
Code:
int change(int c0) {
static int counter = 0;
return (c0 >= 'A' && c0 <= 'Z') ? ((c0 + counter++) % 26 + 'A') : c0;
}
int change(int c0, int c1) {
return (c0 >= 'A' && c0 <= 'Z') ? ((c0 + c1) % 26 + 'A') : c0;
}
// Call change(-1) to initialize the MTF table.
int change(int c0) {
static int mtf[26];
int i, c0b = c0;
if (c0 == -1)
for(int i = 0; i < 26; i++) mtf = 'A' + i;
else if (c0 >= 'A' && c0 <= 'Z') {
// Maybe it's not the best MTF implementation.
for(c0b = 0; c0b < 25 && c0 != mtf[c0b]; c0b++) ;
for(i = c0b; i > 0; i--) mtf = mtf[i - 1];
mtf[0] = c0b += 'A';
}
return c0b;
}