fork download
  1. #include <stdio.h>
  2.  
  3. int isVowel(char ch)
  4. {
  5. if (ch >= 'A' && ch <= 'Z')
  6. ch = (ch - 'A') + 'a';
  7. return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
  8. }
  9.  
  10. int removeVowels(char *s)
  11. {
  12. int removed = 0;
  13.  
  14. if (s)
  15. {
  16. while (*s != '\0')
  17. {
  18. char ch = *s++;
  19.  
  20. if (isVowel(ch) && (*s == ch))
  21. {
  22. char *src = s, *dst = s;
  23.  
  24. do {
  25. ++src;
  26. ++removed;
  27. }
  28. while (*src == ch);
  29.  
  30. while (*src != '\0') {
  31. *dst++ = *src++;
  32. }
  33.  
  34. *dst = '\0';
  35. }
  36. }
  37. }
  38.  
  39. return removed;
  40. }
  41.  
  42. int main()
  43. {
  44. char s[] = "Estaa e umaa string coom duuuplicadoos";
  45. int removed = removeVowels(s);
  46. printf("%s\n# Removed: %d", s, removed);
  47. return 0;
  48. }
Success #stdin #stdout 0s 4872KB
stdin
Standard input is empty
stdout
Esta e uma string com duplicados
# Removed: 6