HELLO;
see this quastion , i tried to solve it , but there is sometjing wrong , i do not know it
because no errors accur !
A 5 letter word x is hidden in a string y such that the first two letters of x are the first two letters of y and the third letter of x is the middle letter of y and the last two letters of x are the last two letters of y. Note that y is any string with length greater than 5.
For example, the 10-letter string grabcefgat hides the 5-letter word great.
And the 7-letter string enatber hides the 5-letter word enter.this is the code :
string extract(string y)
{ int len=y.size();
string x;
for (int i=0;i<5;i++)
{
switch(i)
{
case 0: x[i]=y[i];break;
case 1:x[i]=y[i];break;
case 2:x[i]=y[len/2];break;
case 3:x[i]=y[len-1];break;
case 4:x[i]=y[len-2];break;
}
}
return x;
}
int main ()
{
string a,b;
cout<<"Enter a string :";
cin>>a;
b=extract(a);
cout<<"\n\nThe hidden word is "<<b<<endl;
return 0; }