Advertisement
SergeyPGUTI

8.1.11

Feb 14th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int count(char a[], char b[])
  9. {
  10.     int counter=0;
  11.     int lengthA=strlen(a);
  12.     int lengthB=strlen(b);
  13.     for (int i=0;i<lengthA;i++)
  14.     {
  15.         for (int j=0;j<lengthB;j++)
  16.         {
  17.             if (a[i]==b[j])
  18.             {
  19.                 counter++;
  20.                 break;
  21.             }
  22.         }
  23.     }
  24.     return counter;
  25. }
  26.  
  27. int main()
  28. {
  29.     char str[30]="Hello";
  30.     cout<<count("abracadabra", "bax");
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement