1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <iostream>
int main ()
{
char original[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
char substitute[10] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
char line[] = "123";
int index = 0;
while(line[index])
{
int i = -1;
while(line[index] != original[++i]) //finds index of character in original array
;
line[index++] = substitute[i]; //Replaces it with corresponding character from substitute array
}
std::cout << line;
}
|