I explain you the working of this program.
step 1: enter the no. of time you want to run the loop.
step 2: enter two strings s1 and s2.
output : it will give you a string s3 that does not contain any character from string s2.
problem: I am unable to understand the working of for loop, and why the value of hash is 257, and how is loops working.
The code is given below.
#include <iostream>
using namespace std;
#include<string.h>
int main()
{
int t;
cout<<"enter any no. to run the loop"<<endl;
cin>>t;
while(t--)
{
string s1,s2,s3;
int i,j,l1,l2;
cout<<"enter two strings s1 and s2"<<endl;
cin>>s1>>s2;
l1=s1.length( );
l2=s2.length( );
int hash[257];
for(i=0;i<257;i++)
{
hash[i]=0;
}
for(i=0;i<l2;i++)
{
hash[s2[i]]++;
}
for(i=0;i<l1;i++)
{
if(hash[s1[i]]==0)
s3=s3+s1[i];
}
cout<<s3<<endl;
}
return 0;
}