Quick actions

cmd+k|ctrl+k

Navigation

Languages

dictionary problem(z)

Snippet info

Language

Cpp

Visibility

public

Author

gsubhikaran

Created

2019-06-21T11:36:34Z

Updated

2019-06-21T11:36:34Z

#include <iostream>
using namespace std;
int g=0;
bool check=false;

void dict(string s)
{
    string dictionary[]={"i","like","ice","cream","icecream"};
    int size=sizeof(dictionary)/sizeof(dictionary[0]);
     for(int i=0;i<size;i++)
      { 
        if(dictionary[i].compare(s)==0)
        {
            cout<<s<<' ';
            g +=s.size();
            check=true;
            
            
        }    
      }
    
}


 void fn(string s)
 {
     int size=s.size();
    
    for(int j=0;j<=size;j++) 
   {  for(int i=0;i<=size;i++)
     {
         dict(s.substr(g,size-i));
         if(check)
         break;
        
         
         
     }
     check=false;
     
   }
     
     
     
 }
int main() {
    fn("ilikeiceicecream");
     
      
    
    return 0;
}
INFO