that_one_nigga_you_k

prototipo ctrl+f

Jul 5th, 2023 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5.     char teste[25] ;
  6.     char achar[25] ;
  7.  
  8.     printf("digite o texto: ");
  9.     scanf("%[^\n]", &teste);
  10.     getchar();
  11.    
  12.     printf("digite o texto de interesse: ");
  13.     scanf("%[^\n]", &achar);
  14.     getchar();
  15.    
  16.     int achei = 0, tag = 1;
  17.  
  18.     for (int i = 0; i < strlen(teste) && achei != 1; i++) {
  19.         if (achar[0] == teste[i]) {
  20.             tag = 1;
  21.             for (int j = 1; j < strlen(achar) && tag != 0; j++) {
  22.                 if (achar[j] != teste[i + j]) {
  23.                     tag = 0;
  24.                 }
  25.             }
  26.             if (tag == 1) {
  27.                 achei = 1;
  28.             }
  29.         }
  30.     }
  31.  
  32.     printf("%d", achei);
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment