Advertisement
ismail5g

Test case Problem

Feb 25th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5.   int i, t, c;
  6.   char ch[1000], ch1[1000];
  7.   scanf("%d", &t);
  8.   while(t--){
  9.     c=0;
  10.     scanf("%[^\n]", ch);
  11.     scanf("%s", ch1);
  12.     for(i=0; i<strlen(ch); i++){
  13.       if(ch1[0]==ch[i]){
  14.         c++;
  15.       }
  16.     }
  17.     if(c>0)
  18.       printf("Occurrence of '%c' in '%s' = %d\n", ch1[0], ch, c);
  19.     else
  20.       printf("'%c' is not present\n", ch1[0]);
  21.   }
  22.   return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement