Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void troca(char *string);
  5. void minuscula(char *string);
  6. int quantidade(char *string, char letra);
  7.  
  8. int main(void)
  9. {
  10. char string[80];
  11. gets(string);
  12. minuscula(string);
  13. troca(string);
  14. puts(string);
  15. }
  16.  
  17. void troca(char *string)
  18. {
  19. int qtd = strlen(string), i, j;
  20. for (i = 0; i < qtd; i++)
  21. {
  22. if( *(string + i) == 'z')
  23. {
  24. *(string + i) = 'a';
  25. }
  26. else if(*(string + i) ==' ')
  27. {
  28. //não faz nada
  29. }
  30. else
  31. {
  32. *(string + i) += 1;
  33. }
  34. }
  35. for(i = qtd - 1; i >= 0; i--)
  36. {
  37. if (quantidade(string, *(string + i)) > 0)
  38. {
  39. if (*(string + i) == 'z')
  40. {
  41. *(string + i) = 'a';
  42. }
  43. else if (*(string + i) == ' ')
  44. {
  45.  
  46. }
  47. else
  48. {
  49. *(string + i) += 1;
  50. i++;
  51. }
  52. }
  53. }
  54. }
  55.  
  56. int quantidade(char *string, char letra)
  57. {
  58. int cont = 0;
  59. while(*string != '\0')
  60. {
  61. if(*string == letra) cont++;
  62. string++;
  63. }
  64. return cont - 1;
  65. }
  66.  
  67. void minuscula(char *string)
  68. {
  69. while(*string != '\0')
  70. {
  71. if (*string >= 'A' && *string <= 'Z')
  72. {
  73. *string += 32;
  74. }
  75. string++;
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement