fork download
  1. #include <stdio.h>
  2.  
  3. unsigned char ArrOne[][2] = {
  4. {1, 'a'},
  5. {7, 'e'},
  6. {5, 'c'},
  7. {4, 'x'},
  8. {2, 'r'}
  9. };
  10. unsigned char ArrTwo[][2] = {
  11. {7, 'k'},
  12. {9, 'z'},
  13. {1, 'y'},
  14. {3, 'x'},
  15. {2, 'b'}
  16. };
  17.  
  18. int main(void) {
  19. unsigned char one[128] = {0};
  20. for (int i = 0 ; i != 5 ; i++) {
  21. one[ArrOne[i][1]] = ArrOne[i][0];
  22. }
  23. char two[128] = {0};
  24. for (int i = 0 ; i != 5 ; i++) {
  25. two[ArrTwo[i][0]] = ArrTwo[i][1];
  26. }
  27. char lookup[128];
  28. for (int c = 0 ; c != 128 ; c++) {
  29. char r = two[one[c]];
  30. lookup[c] = r ? r : c;
  31. }
  32. char str[] = "There is my text.";
  33. printf("%s\n", str);
  34. for (char *p = str ; *p ; p++) {
  35. *p = lookup[(int)*p];
  36. }
  37. printf("%s\n", str);
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
There is my text.
Thkbk is my tkxt.