Created
December 4, 2014 12:53
-
-
Save anonymous/3f679a29081cbf23c4c6 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
void Tabela(){ | |
int ocorrencia[qtdAlf][qtdPadrao]; | |
for (int i=0; i<qtdAlf; i++) | |
{ | |
for(int j=0; j<qtdPadrao; j++) | |
{ | |
if (alfabeto[i] == padrao[j]) | |
ocorrencia[i][j] = 1; | |
else | |
ocorrencia[i][j] = 0; | |
} | |
} | |
printf("\nTabela de Ocorrencias: \n"); | |
for (int i=0; i<qtdAlf; i++) | |
{ | |
printf("\n%c: ", alfabeto[i]); | |
for(int j=0; j<qtdPadrao; j++) | |
{ | |
printf("%d", ocorrencia[i][j]); | |
} | |
} | |
int Rant[qtdPadrao], Ratual[qtdPadrao]; | |
Rant[0]=1; | |
for(int c=1; c<qtdPadrao; c++) | |
Rant[c]=0; | |
printf("\n\nTabela Sift-And: R Atual \n"); | |
for (int a=0; a<qtdTexto; a++) | |
{ | |
for (int b=0; b<qtdAlf; b++) | |
{ | |
if (texto[a] == alfabeto[b]) | |
{ | |
printf("\n%c: ",texto[a]); | |
for (int d=0; d<qtdPadrao; d++) | |
{ | |
Ratual[d] = Rant[d] && ocorrencia[b][d]; | |
} | |
for (int f=qtdPadrao-1; f>0; f--) | |
Rant[f] = Rant[f-1]; | |
Rant[0]=1; | |
for (int e=0; e<qtdPadrao; e++) | |
{ | |
printf("%d", Ratual[e]); | |
} | |
if (Ratual[qtdPadrao-1] == 1) | |
{ | |
printf(" Casamento!"); | |
for (int h=0; h<qtdPadrao;h++) | |
texto[a-h] = toupper(texto[a-h]); | |
} | |
} | |
} | |
} | |
rewind(arq); | |
fprintf(arq,"%s",texto); | |
} | |
int main(){ | |
printf("Informe o alfabeto - Ex.: (abcd101): "); | |
gets(alfabeto); | |
qtdAlf = strlen(alfabeto); | |
printf("Informe o Padrão - Ex.: (ad0): "); | |
gets(padrao); | |
qtdPadrao = strlen(padrao); | |
printf("Informe o nome do arquivo: "); | |
gets(nmArquivo); | |
fflush(stdin); | |
arq = fopen(nmArquivo, "r+"); | |
if (arq == NULL) | |
{ | |
printf("Problemas na abertura do arquivo\n"); | |
} | |
while((caracter = getc(arq)) != EOF) | |
{ | |
texto[qtdTexto]=caracter; | |
qtdTexto = qtdTexto+1; | |
} | |
Tabela(); | |
rewind(arq); | |
fclose(arq); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment