Advertisement
apl-mhd

Sub string

May 7th, 2024
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7.     char str1[100];
  8.     char str2[100];
  9.  
  10.     gets(str1);
  11.     scanf("%s", str2);
  12.  
  13.     int flag;
  14.     for (int i = 0; str1[i] != '\0'; i++)
  15.     {
  16.         flag = 1;
  17.         for (int j = 0; str2[j] != '\0'; j++)
  18.         {
  19.             if (str1[i] != str2[j])
  20.             {
  21.                 flag = 0;
  22.                 break;
  23.             }
  24.             i++;
  25.         }
  26.         if (flag == 1)
  27.         {
  28.             break;
  29.         }
  30.     }
  31.  
  32.     if (flag == 1)
  33.     {
  34.         printf("Yes\n");
  35.     }
  36.     else
  37.     {
  38.         printf("No\n");
  39.     }
  40.  
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement