Advertisement
apl-mhd

subs string case insentive

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