<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. scan for inputs
  4. if length of string >256 the display error message
  5. show cipher text at output
  6. show plain text at output
  7. substitute character value +1 for 1st character
  8. keep substituting each character for next character value +1
  9. display next substitution
  10. if all substitutions made then display encrypted text at output
  11. END
  12. */
  13.  
  14. #include <stdio.h>
  15. int cSize;
  16. int pSize;
  17.  
  18. int main( void )
  19. {
  20. scanf("%d", &cSize);
  21. char cText[cSize];
  22.    for (int i = 0; i<= cSize;i++)
  23. {
  24. scanf("%c",&cText[i]);
  25. printf("%c",cText[i]);
  26. }
  27. scanf("%d",&pSize);
  28. char pText[pSize +1];
  29. char nText[pSize +1];
  30.    for (int i = 0; i <= pSize; i++)  
  31. {
  32.    scanf("%c", &pText[i]);
  33.    printf("%c",pText[i]);
  34. }
  35.    printf("\n");
  36.    for (int i = 1; i <= pSize; i++)
  37. {
  38.    nText[i] = pText[i];       
  39. }
  40. int pSub;
  41. int cSub;
  42. int changed;
  43.    for (int i = 1; i <= pSize; i++)   
  44. {
  45.    for (int j = 1; j <= cSize; j++)   
  46. { 
  47.   pSub= pText[i] - '0';
  48.   cSub= cText[j] - '0';          
  49.    for (int i = 1; i <= pSize; i++)   
  50. {
  51.    for (int j = 1; j <= cSize; j++)
  52. {
  53.    if (pSub == cSub && j != cSize && changed == 0)
  54. {
  55. nText[i] = cText[j+1];
  56. printf("substitute %c with %c\n",cText[j+1]);
  57. changed = 1;
  58. }
  59.  
  60.    else if (pSub == cSub && j == cSize && changed ==0)
  61. {
  62.  nText[i] = cText[1];
  63.  printf("substitute %c with %c \n",cText[j],cText[1]);
  64.  changed = 1;
  65. }     
  66.  changed = 0;
  67. }     
  68. {
  69. for (int i =1; i<=pSize; i++);
  70. }
  71. printf("%c",nText[i]);
  72. }