<mosaic.cnfolio.com>
PROGRAM
  1. /*START
  2. length of cipher key and cipher key are inputted
  3. length of plain text and plain text are inputted
  4. IF
  5. cipher key smaller than two or larger than sixteen
  6. THEN
  7. display error message
  8. ELSE
  9. read cipher key
  10. IF
  11. cipher key contains a number
  12. THEN
  13. display error message
  14. IF
  15. cipher key contains a space
  16. THEN
  17. display error message
  18. IF
  19. cipher key contains upper case letters
  20. THEN
  21. display error message
  22. IF
  23. length of plain text is smaller than four or larger than two hundred and fifty six
  24. THEN
  25. display error message
  26. ELSE
  27. read plain text
  28. IF
  29. plain text contains a number
  30. THEN
  31. display error message
  32. IF
  33. plain text contains upper case letters
  34. THEN
  35. display error message
  36. ELSE
  37. substitute a letter in the plain text that matches the first letter in the cipher text with the second letter in the cipher text
  38. THEN
  39. display the new plain text
  40. THEN
  41. increment the cipher by one
  42. THEN
  43. then substitue the letter into the original plain text
  44. THEN
  45. display new plain text with the previous changes
  46. IF
  47. all letters have been substitued in then stop
  48. END IF
  49. END IF
  50. END IF
  51. END IF
  52. END IF
  53. END IF
  54. END IF
  55. END IF
  56. END */
  57.  
  58. #include <stdio.h>
  59. #include <ctype.h>
  60.  
  61. int main( void )
  62. {
  63. int length_of_cipher;
  64. char cipher_key;
  65. int length_of_plain;
  66. char plain_text;
  67.  
  68. //length of cipher error message
  69. scanf("%d",&length_of_cipher);
  70.   if(length_of_cipher <2 || length_of_cipher >16)
  71.   {
  72.   printf("Error, length of cipher not in the correct range, enter a number between 2 and 16");//cipher key error message//
  73.   return (0);
  74.   }
  75.  cipher_key=getchar();
  76.   scanf("%c",&cipher_key);
  77.   if ( isdigit( cipher_key ) )
  78.   {printf( "Numerical\n" );
  79.   return 0;
  80.   }
  81.  
  82.   scanf("%c",&cipher_key);
  83.   if ( isspace( cipher_key ) )
  84.   {printf( "space\n" );
  85.   return 0;
  86.   }
  87.   //length of plain text error message
  88.   scanf("%d",&length_of_plain);
  89.   if(length_of_plain <4 || length_of_plain >256)
  90.   {
  91.   printf("Error, length of plain not in the correct range, enter a number between 4 and 256");//plain text error message//
  92.   return (0);
  93.   }
  94.   plain_text=getchar();
  95.   scanf("%c",&plain_text);
  96.   if ( isdigit( plain_text ) )
  97.   {printf( "Numerical\n" );
  98.   return 0;
  99.   }
  100.   //step 1
  101.  
  102.  
  103.  {
  104.   printf("substitute %c with %c\n",cipher_key+1,cipher_key);
  105.   }
  106.  
  107.  
  108.   if ("%c",plain_text == "%c",cipher_key+1) {
  109.   printf("%c\n",cipher_key);
  110.   }
  111.   else
  112.  { printf("%c",plain_text);
  113. }
  114.  
  115.   {
  116.   printf("substitute %c with %c\n",cipher_key,cipher_key+1);
  117.   }
  118.  
  119.   if ("%c",plain_text == "%c",cipher_key) {
  120.   printf("%c\n",cipher_key);
  121.   }
  122.   else
  123.  { printf("%c",plain_text);
  124. }
  125.   }
  126.  
  127.  
  128.  /* {
  129.   scanf("%c",cipher_key);
  130.   printf("\nstep 2 substitute %c with %c",cipher_key,cipher_key+1);
  131.   }*/