kikit
7/4/2016 - 3:45 PM

Extraction of secret message

Extraction of secret message

/*
http://ideone.com/lvl8Zf
http://www.practice.geeksforgeeks.org/problem-page.php?pid=956
*/


#include <iostream>
using namespace std;

int main() {
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		int len = s.size();
		int cur = 0, flag=0, count=0;
		for(int i=0; i< len; i++){
			cur = i;
			if(s[i] == 'L' && s[i+1] == 'I' && s[i+2] == 'E'){
				i += 2;
				count++;
			}
			else{
				cout << s[i];
				flag = 1;
				count = 0;
			}
			if(count == 1 && flag==1){
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}