-
-
Save TopRoupi/07653989d9af54ddcec688579d480791 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void corta(char txt[],int ini,int fim){ | |
ini -= 1; | |
int i; | |
for (i = 0; txt[fim+i] != '\0'; i++) | |
txt[ini+i] = txt[fim+i]; | |
txt[ini+i] = '\0'; | |
} | |
int maiuscula(char letra){ | |
if (letra <= 90 && letra >= 65) | |
return 1; | |
return 0; | |
} | |
int qtd_maiusculas(char texto[]){ | |
int contador = 0; | |
for(int i = 0; texto[i] != '\0'; i++){ | |
if(maiuscula(texto[i])) | |
contador++; | |
} | |
return contador; | |
} | |
int qtd_abreviacoes(char texto[]){ | |
int contador = 0; | |
for(int i = 0; texto[i] != '\0'; i++){ | |
if(maiuscula(texto[i]) && texto[i+1] == '.') | |
contador++; | |
} | |
return contador; | |
} | |
void abrevia(char nome[]){ | |
if((qtd_maiusculas(nome) - qtd_abreviacoes(nome)) == 2) | |
return; | |
else{ | |
int ignorar = qtd_abreviacoes(nome) + 1; | |
for (int i = 0; !(maiuscula(nome[i])); i++) | |
{ | |
printf("a"); | |
} | |
} | |
} | |
int main(void){ | |
char txt[30] = "Breno Nunes Galvao"; | |
// corta(txt, 8, 11); | |
// puts(txt); | |
// printf("%d\n", qtd_maiusculas(txt)); | |
// printf("%d\n", qtd_abreviacoes(txt)); | |
abrevia(txt); | |
puts(txt); | |
return 0; | |
} | |
//B r e n o N u n e s G a l v a o \0 | |
//1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment