Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <vector>
- #include <typeinfo>
- using namespace std;
- class Word {
- private:
- int length;
- string word;
- public:
- Word()
- {
- length = 0;
- word = "";
- }
- Word(int length, string word)
- {
- this->length = length;
- this->word = word;
- }
- Word(const Word& obj)
- {
- this->length = obj.length;
- this->word = obj.word;
- }
- bool checkFL(){
- if(this->word[0] == this->word[this->length-1]){
- return true;
- }else{
- return false;
- }
- }
- bool check3k(){
- int count = 0;
- for (int i = 0; i < this->length; i++) {
- if(this->word[i] == 'k'){
- count++;
- }
- }
- if(count == 3){
- return true;
- }else{
- return false;
- }
- }
- };
- int main(int argc, const char * argv[]) {
- string value = "Hello how are you hah kknjnk";
- istringstream iss;
- iss.str(value);
- for (int i = 0; i < value.size(); i++) {
- string val;
- iss >> val;
- Word word((int)val.size(), val);\
- if(word.checkFL()){
- cout << val <<endl;
- }
- if(word.check3k()){
- cout << val <<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement