Você está na página 1de 3

#include <stdio.

h>
#include <stdlib.h>
#include <string.h>

bool existe(int teste[], int tam){


for(int t = 0; t < tam; t++){
if (teste[i] == 0){
return false
}
}
return true
}

bool existe(char palavra[], char frase[]){


int teste[strlen(palavra)];
int aux
if(strlen(palavra) > strlen(frase)){
return false;
}

if(strcmp(palavra, frase){
return true;
}
for (int i = 0; i <= strlen(frase) - strlen(palavra); i++){
if(frase[i] == palavra[0]){
aux = i;
for (int j = o; j < strlen(palavra); j++){
if (palavra[j) == frase[aux]){
teste[j] = 1;
aux++;
}
}
if(testar(teste, strlen(palavra))){
return true;
}
}
}
return false;
}

#include <stdio.h> // biblioteca standard de Input/Output


main(){

int m;
int n;
char alfabeto[] =
{'a','b','c','d','e','f','g','h','i','j','l','m','n','o','p','q','r','s','t','u','v
','x','z'};
printf("informe o tamanho da matriz: ");
scanf("%d", &m);
n = m;
int matriz[m][n];
int r = 0
for(int j = 0; j < m+1; i++)
{
for(int i = 0; i < n+1;i++)
{
matriz[j][i] = alfabeto[r]
r++
}
}
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

bool existe(char palavra[], char frase[]){


int teste[ strlen(palavra) ];
int aux;
bool ok;

if( strlen(palavra) > strlen(frase) ){

return false;
}

if( strcmp(palavra,frase) ==0 ){


return true;
}

for(int i=0; i <= strlen(frase) - strlen(palavra); i++){


if(frase[i]==palavra[0]){

for(int k=0;k<strlen(palavra);k++)
teste[k]=0;

aux=i;
for(int j=0;j<strlen(palavra);j++){
if(palavra[j]==frase[aux]){
teste[j]=1;
aux++;
}
}

ok=true;
for(int m=0;m<strlen(palavra);m++){
if(teste[m]==0){
ok=false;
}
}

if( ok ){
return true;
}
}
}
return false;
}

int main(){
char frase[] = "O carro e azul";
char palavra[] = "l";
if(existe(palavra,frase)){
printf("\n\nA palavra existe\n\n");
}else{
printf("\n\nA palavra nao existe\n\n");
}

system("pause");
return 0;

Você também pode gostar