Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int lucky(string a,char i,char j)
- { char c;int count=0;char d;
- for (int l=0;l<a.length();l++)
- { c=a[l];
- if (c==j)
- {
- for (int t=0;t<l;t++)
- {
- d=a[t];
- if (d==i) count++;
- }
- }
- }
- return count;
- }
- int main()
- {
- string b;int x;
- cin>>b;
- cin>>x;
- char m[x];
- char n[x];
- for (int p=0;p<x;p++)
- {cin>>m[p]>>n[p];
- }
- for (int r=0;r<x;r++)
- { cout<<lucky(b,m[r],n[r])<<endl;
- }
- /*system("pause");*/
- return 0;
- }
Add Comment
Please, Sign In to add comment