<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. the cipher key must be 2 to 16 characters in length
  3. the cipher key must contain only lower case characters
  4. the plain text to encrypt must contain 4 to 256 characters in length and must contain lower case characters
  5. use N to indicate the current position in the cipher key
  6. N must equal to 1
  7.  
  8.  
  9. pseudo code
  10. --------------------------------
  11. Begin the main method
  12.         Declaring and initializing arrays variables and arrays
  13.         Get the values of the cipher and plain text form the user
  14.       Start loop to check the ‘step’ limit has reached or not
  15.                  Check if the loop limit reached
  16.                                If yes, assign the last value to first
  17.                Displaying the step
  18.          
  19.             Start loop to check the character
  20.                     Start loop to check whether the character is already encrypted
  21.                                      If yes, flag it
  22.             End loop
  23.        If the flag is not set for the current character address
  24.                          Encrypt it
  25.  
  26.   Display the encrypted string
  27.   Increase the value of step
  28. End loop
  29. End main
  30.  
  31. */
  32.  
  33.  #include<stdio.h>
  34.  
  35.      #include<string.h>
  36.  
  37.     void main()
  38.      {
  39.  
  40.            char k[27],c[30],temp;
  41.            int  index,x,j,y,step=1,d,length=0,value=0,g,flag=0,save[20];
  42.           scanf("%d",&x);
  43.           scanf("%s",&c);
  44.           scanf("%d",&j);
  45.       scanf("%c",&temp); // temp statement to clear buffer
  46.    scanf("%[^\n]",k);
  47.     length=strlen(c);
  48.    for (y=0;y<length;y++)
  49.     {
  50. if(y==length-1)
  51. {
  52.     c[y+1]=c[0];
  53. }
  54.  
  55. printf("step %d substitute %c with %c \n",step,c[y],c[y+1]);
  56.  
  57.  
  58. for (d=0;d<strlen(k);d++)
  59. {
  60.     for(g=0;g<strlen(save);g++)
  61.     {
  62.         if(&k[d]==save[g])
  63.         {
  64.             flag=1;
  65.         }
  66.     }
  67. if(flag!=1)
  68.     {
  69.  
  70.         if (k[d]==c[y])
  71.            {
  72.  
  73.             k[d]=c[y+1];
  74.              save[value]=&k[d];
  75.                value++;
  76.             }
  77.  
  78.      }
  79. }
  80.  puts(k);
  81.  step++;
  82.     }
  83.  
  84.                 }