Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <vector>
  5. #include <typeinfo>
  6.  
  7. using namespace std;
  8.  
  9. class Word {
  10. private:
  11. int length;
  12. string word;
  13. public:
  14. Word()
  15. {
  16. length = 0;
  17. word = "";
  18. }
  19.  
  20. Word(int length, string word)
  21. {
  22. this->length = length;
  23. this->word = word;
  24. }
  25.  
  26. Word(const Word& obj)
  27. {
  28. this->length = obj.length;
  29. this->word = obj.word;
  30. }
  31.  
  32. bool checkFL(){
  33. if(this->word[0] == this->word[this->length-1]){
  34. return true;
  35. }else{
  36. return false;
  37. }
  38. }
  39.  
  40. bool check3k(){
  41. int count = 0;
  42. for (int i = 0; i < this->length; i++) {
  43. if(this->word[i] == 'k'){
  44. count++;
  45. }
  46. }
  47. if(count == 3){
  48. return true;
  49. }else{
  50. return false;
  51. }
  52. }
  53.  
  54. };
  55.  
  56.  
  57.  
  58. int main(int argc, const char * argv[]) {
  59. string value = "Hello how are you hah kknjnk";
  60. istringstream iss;
  61. iss.str(value);
  62. for (int i = 0; i < value.size(); i++) {
  63. string val;
  64. iss >> val;
  65. Word word((int)val.size(), val);\
  66.  
  67. if(word.checkFL()){
  68. cout << val <<endl;
  69. }
  70.  
  71. if(word.check3k()){
  72. cout << val <<endl;
  73. }
  74. }
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement