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 checar(int tamanho, char x[tamanho], int tamanho2, char y[tamanho2], int posicao)
- {
- if(posicao == tamanho2)
- {
- return 1;
- }
- else if(x[posicao] == y[posicao])
- {
- checar(tamanho,x,tamanho2,y,posicao+1);
- }
- else
- return 0;
- }
- void moverString(int tamanho, char x[tamanho], int tamanho2, int posicao)
- {
- if(posicao == tamanho)
- {
- return;
- }
- else
- {
- x[posicao] = x[posicao+tamanho2];
- moverString(tamanho, x, tamanho2, posicao+1);
- }
- }
- void comparar(int tamanho, char x[tamanho], int tamanho2, char y[tamanho2], int posicao, int posicao2)
- {
- if(posicao == tamanho)
- {
- return;
- }
- if(x[posicao]== y[posicao2])
- {
- if(checar(tamanho,x,tamanho2,y,posicao+1))
- {
- moverString(tamanho, x, tamanho2, posicao);
- }
- }
- else
- {
- return comparar(tamanho, x,tamanho2, y, posicao+1, posicao2);
- }
- }
- int main() {
- char string[51];
- char letra[51];
- scanf("%s %s", string, letra);
- int tamanho = strlen(string);
- int tamanho2 = strlen(letra);
- comparar(tamanho,string,tamanho2,letra,0,0);
- printf("%s\n", string);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement