Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. //palindromeround2
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #define MAX_CHARACTER 4096
  6.  
  7.  
  8. int caseShifter(int input);
  9.  
  10. int evenPalindromeTest(char input[]);
  11.  
  12. int oddPalindromeTest(char input[]);
  13.  
  14. int filterLengthCounter(char input[]);
  15.  
  16. int main(void) {
  17.  
  18. char inputArray[MAX_CHARACTER] = {0};
  19.  
  20. char filteredArray[MAX_CHARACTER] = {0};
  21.  
  22. int arrayCounter = 0;
  23. int filterCounter = 0;
  24.  
  25. int shiftedCase;
  26.  
  27. int filterLength;
  28.  
  29. printf("Enter a string: ");
  30.  
  31. inputArray[arrayCounter] = getchar();
  32.  
  33. while(arrayCounter < MAX_CHARACTER && inputArray[arrayCounter] != '\n') {
  34.  
  35. if('a' <= inputArray[arrayCounter] && inputArray[arrayCounter] <= 'z'){
  36.  
  37. filteredArray[filterCounter] = inputArray[arrayCounter];
  38.  
  39. filterCounter = filterCounter + 1;
  40. }
  41.  
  42. else if('A' <= inputArray[arrayCounter] && inputArray[arrayCounter] <= 'Z'){
  43.  
  44. shiftedCase = caseShifter(inputArray[arrayCounter]);
  45.  
  46. filteredArray[filterCounter] = shiftedCase;
  47.  
  48. filterCounter = filterCounter + 1;
  49. }
  50.  
  51. arrayCounter = arrayCounter + 1;
  52.  
  53. inputArray[arrayCounter] = getchar();
  54.  
  55.  
  56. }
  57.  
  58. filterLength = filterLengthCounter(filteredArray);
  59.  
  60. printf("%d\n", filterLength);
  61.  
  62.  
  63. return 0;
  64. }
  65.  
  66. int caseShifter(int input){
  67.  
  68. int output;
  69.  
  70. output = input + 32;
  71.  
  72. return output;
  73. }
  74.  
  75. int evenPalindromeTest(char input[]){
  76. int output = 0;
  77. return output;
  78. }
  79.  
  80. int oddPalindromeTest(char input[]){
  81. int output = 0;
  82. return output;
  83. }
  84.  
  85. int filterLengthCounter(char input[]){
  86.  
  87. int counter = 0;
  88. int length = 0;
  89.  
  90. while (counter != '\n'){
  91.  
  92. counter = counter + 1;
  93.  
  94. }
  95.  
  96. length = counter;
  97.  
  98. return length;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement