Skip to content

Commit 99a70be

Browse files
authored
Create Lecture - 19.cpp
1 parent 3a12b8f commit 99a70be

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Lecture - 19.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
// ** -- code of "Studying alphabet " --Code chef -- **
3+
#include <iostream>
4+
using namespace std;
5+
int main()
6+
{
7+
string s; cin>>s;
8+
int a[26]={0}; // we put the value 0 in all the blocks
9+
int len = (int)s.size(); // length of string
10+
for(int i=0;i<len;i++)
11+
{
12+
char x = s[i]; // lets suppose x ='c'
13+
int p = int(x); // p =99
14+
p = p-97; // index of that character // p =2
15+
a[p]=1;
16+
}
17+
int n; cin>>n;
18+
for(int i=0;i<n;i++)
19+
{
20+
int count=0; // no. of charcter that not present in string s
21+
string k; cin>>k; // k--> words
22+
for(int j=0;j<k.size();j++)
23+
{
24+
char z = k[j]; // let's supose z= 'f'
25+
int h = int(z); // h=102
26+
h = h-97; // h=5
27+
if(a[h]==0)
28+
count++;
29+
else
30+
count=count;
31+
}
32+
if(count>0)
33+
cout<<"No"<<endl;
34+
else
35+
cout<<"Yes"<<endl;
36+
37+
}
38+
}

0 commit comments

Comments
 (0)