Guest User

Untitled

a guest
Apr 16th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.37 KB | None | 0 0
  1. /*
  2.  *  removeVowels.c
  3.  *  comp1927 sample pracExam
  4.  *  write a function with the specified typesignature which
  5.  *  given a list of characters returns a pointer to the list with the
  6.  *  nodes containing lowercase vowels removed.
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <assert.h>
  12. #include "list.h"
  13.  
  14. list removeVowels (list word);
  15.  
  16. // a sample stub non-working solution which compiles
  17. // but does not pass the tests
  18. //
  19. // change anything you wish below here  
  20. // and add any local static functions you wish
  21. // your code must comply with the course
  22. // style guide
  23. //
  24.  
  25. list removeVowels (list word) {
  26.    list before, after;
  27.    after = word->rest;
  28.    before = after;
  29.    if (after == NULL) {
  30.    } else if (after->rest== NULL) {
  31.       if (after->value == 'a' ||
  32.           after->value == 'e' ||
  33.           after->value == 'i' ||
  34.           after->value == 'o' ||
  35.           after->value == 'u')  {
  36.          word->rest=NULL;
  37.       }
  38.    } else {
  39.       while (after != NULL) {
  40.          if (after->value == 'a' ||
  41.              after->value == 'e' ||
  42.              after->value == 'i' ||
  43.              after->value == 'o' ||
  44.              after->value == 'u')  {  
  45.                        
  46.             after=after->rest;
  47.             before->rest=after;
  48.          }
  49.       before = after;
  50.       after=after->rest;
  51.       }
  52.    }
  53.    return word;
  54. }
Add Comment
Please, Sign In to add comment