Problem 28

7 comments on “Problem 28”


  • Pramit

    String check(String search, String pattern) {
    boolean flag = false;
    String result = “”;
    char char_search[] = search.toCharArray();
    char char_pattern[] = pattern.toCharArray();

    for (int i=0; i<char_pattern.length; i++) {
    char c = char_pattern[i];
    for (int j=0; j<char_search.length; j++) {
    if(c == char_search[j]) {
    flag = true;
    break;
    } else
    flag = false;
    }
    if(flag == false)
    break;
    }
    result = (flag)? "TRUE" : "FALSE";
    return result;
    }


  • amit

    #include
    #include
    int sub_str(char [],char []);
    int main()
    {
    int result;
    char search[100];
    char patern[100];
    scanf(“%s”,search);
    scanf(“%s”,patern);
    result=sub_str(search,patern);
    if(result==-1)
    printf(“Substring not Found”);
    else
    printf(“Substring found”);

    }
    int sub_str(char search[],char patern[])
    {
    int i,j,k,l;
    l=strlen(patern);
    for(i=0;search[i+l-1];i++)
    {
    k=i;
    for(j=0;j<=l-1;j++)
    {
    if(search[k]!=patern[j])
    break;
    k++;
    }

    if(j==l)
    return(i);

    }
    return -1;
    }


  • VIVEK KUMAR

    str1=’Hello how are you’
    str2=’hello’
    if str2.lower() in str1.lower():
    print(‘True’)
    else:
    print(‘False’)


  • SWATI

    import java.util.*;
    public class Main
    {
    public static void main (String[]args)
    {
    Scanner sc = new Scanner (System.in);
    String mainStr = sc.nextLine ();
    String searchStr = sc.nextLine ();

    if (mainStr.contains (searchStr))
    System.out.println (“TRUE”);
    else
    System.out.println (“FALSE”);

    }
    }


  • Mohd Saif

    search_string=input(“Enter the search_string:\n”)
    pattern_string=input(“Enter the pattern_string:\n”)
    if pattern_string in search_string:
    print(“True”)
    else:
    print(“False”)