View Code of Problem 84

#include<bits/stdc++.h>
using namespace std;
void trans(string& str) {
	for(int i=0;i<str.length();i++) {
		if(str[i]>='A'&&str[i]<='Z')
			str[i]=str[i]-'A'+'a';
	}
}
	
int judge(string str) {
	trans(str);
	for(int i=0;i<str.length();i++) { 
		if(str[i]=='s'&&str[i+1]=='a'&&str[i+2]=='l'&&str[i+3]){
			return 1;
		}   
	}
	return 0;
}
int main()
{
	string str;
	while(getline(cin,str)) {
		if(judge(str)) 
			cout<<str<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 84