Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void troca(char *string);
- void minuscula(char *string);
- int quantidade(char *string, char letra);
- int main(void)
- {
- char string[80];
- gets(string);
- minuscula(string);
- troca(string);
- puts(string);
- }
- void troca(char *string)
- {
- int qtd = strlen(string), i, j;
- for (i = 0; i < qtd; i++)
- {
- if( *(string + i) == 'z')
- {
- *(string + i) = 'a';
- }
- else if(*(string + i) ==' ')
- {
- //não faz nada
- }
- else
- {
- *(string + i) += 1;
- }
- }
- for(i = qtd - 1; i >= 0; i--)
- {
- if (quantidade(string, *(string + i)) > 0)
- {
- if (*(string + i) == 'z')
- {
- *(string + i) = 'a';
- }
- else if (*(string + i) == ' ')
- {
- }
- else
- {
- *(string + i) += 1;
- i++;
- }
- }
- }
- }
- int quantidade(char *string, char letra)
- {
- int cont = 0;
- while(*string != '\0')
- {
- if(*string == letra) cont++;
- string++;
- }
- return cont - 1;
- }
- void minuscula(char *string)
- {
- while(*string != '\0')
- {
- if (*string >= 'A' && *string <= 'Z')
- {
- *string += 32;
- }
- string++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement