Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- int main(){
- int regras, linhas; scanf("%d %d", ®ras, &linhas);
- int i, x, k, l, cont = 0, pos = -1, j, tamc, tamt;
- char errada[50][100], certa[50][100], texto[50][100], textoc[50][100], aux[100];
- for(i = 0; i < regras; i++)
- scanf("%s -> %s", errada[i], certa[i]);
- for(i = 0; i < linhas; i++)
- scanf(" %[^\n]s", texto[i]);
- for(i = 0; i < regras; i++){
- for(x = 0; x < linhas; x++){
- for(k = 0; k < strlen(texto[x]); k++){
- if(errada[i][0] == texto[x][k]){
- pos = k;
- cont = 0;
- for(l = 0; l < strlen(errada[i]); l++){
- if(errada[i][l] == texto[x][k+l]){
- //printf("errada = %c\n", errada[i][l]);
- //printf("texto = %c\n", texto[x][k+l]);
- cont++;
- }
- }
- if(cont == strlen(errada[i])){
- for(l = 0; l < pos; l++){
- textoc[i][l] = texto[i][l];
- }
- strcat(textoc[i], certa[i]);
- tamc = strlen(certa[i]);
- tamt = strlen(texto[i]);
- textoc[i][pos+tamc] = " ";
- for(l = 1+pos+tamc; l <= tamt; l++){
- printf("texto = %c\n", texto[i][l]);
- textoc[i][l] = texto[i][l-1];
- }
- printf("%s\n", textoc[i]);
- i = regras;
- x = linhas;
- k = 101;
- }
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement