Janu and Ram are close friends who task a lot about life.They go though a lot of inspiring "Quotes of Life".One fine day they had a small game.According to the game Ram will Read one of the Quote about life from the book and Jannu have to think a word about life in her mind without disclosing it to Ram.Finally once Ram completed reading the quoted Jannu will say if the word she thought in her mind is there in the Quote read by Ram.Can you convert the same scenario to a programming logic ?If the work thought by Jannu was present in the Quote then you have to print "Exists" else print "Dosen't Exists".

 #include <stdio.h>

#include <string.h>

int M,N,i,j,res;

int main()

{int t;

scanf("%d",&t);

while(t--){

 char string[100];

 char p[100];

 scanf("%s%s",string,p);

 M=strlen(p);

 N=strlen(string);

 res=0;

 for(i=0;i<=N-M;i++){

 for(j=0;j<M;j++)

 if(string[i+j]!=p[j])

 break;

 if(j==M){

 res++;

 j=0;

 }

 }

 if(res>0)printf("Exists\n");

 else printf("Dosen't Exists\n");

}




return 0;

}

Comments

Popular posts from this blog

Elavenil has a chessboard with N rows and M columns. In one step, he can choose two cells of the chessboard which share a common edge (that has not been cut yet) and cut this edge. Formally, the chessboard is split into two or more pieces if it is possible to partition its cells into two non-empty subsets S1 and S2 (S1∩S2=∅, |S1|+|S2|=NM) such that there is no pair of cells c1,c2 (c1∈S1,c2∈S2) which share a common edge that has not been cut.Elavenil does not want the board to split into two or more pieces. Compute the maximum number of steps he can perform while satisfying this condition.

The Matriculation school have arranged an Annual Day Function.Volunteers have decorated a floor on various places of the school using Rose and Tulip flowers. But one of the coordinators requested the volunteers to rearrange the decoration like a triangular size.Coordinator also told them that tulips flowers need to be positioned at the middle of the roses

Mukesh and Salima was looking to buy Organic Apples in the nearest fruits shop.But Shop Owner mixed the Hybrid apples in that Apple box. After sometimes Mukesh checking the box, he was confused among organic and hybrid apple. He started to count the hybrid apples. Please help to Mukesh Count the total number of hybrid apples in the box.