Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int wordcompare(string InputWord, string AnswerWord) {
  6.     // ? if : else
  7.     int size = (InputWord.size() < AnswerWord.size()) ? InputWord.size() : AnswerWord.size();
  8.     int DifferenceBetweenWords;
  9.     for(int i= 0; i < size; i++){
  10.         if(InputWord[i] == AnswerWord[i]){
  11.            ++i;
  12.            return DifferenceBetweenWords;
  13.         }
  14.     }
  15. }
  16.  
  17. /*
  18. int main()
  19. {
  20.     int DifferenceBetweenWords;
  21.     string AnswerWord;
  22.      cout << "please enter answer" << endl;
  23.      cin << AnswerWord;
  24.      if(DifferenceBetweenWords != AnswerWord.size() ){
  25.      cout << "please enter first geuss" << endl;
  26.      cin << InputWord;
  27.      wordcmp(InputWord, AnswerWord)
  28.      cout << DifferenceBetweenWords;
  29.      }
  30.      else{
  31.      cout << "YOUW WON!!"}
  32. return 0;
  33. }
  34. */
  35. int main(){
  36.     int WordSimilarityCount;
  37.     string AnswerWord;
  38.     string InputWord;
  39.     cout << "Answer:" << endl;
  40.     cin >> AnswerWord;
  41.     do {
  42.         cout << "Input next geuss (NOTE: Words cannot be longer then " << AnswerWord.size() << " )"<< endl;
  43.         cin >> InputWord;
  44.         cout << wordcompare(InputWord, AnswerWord) << endl;
  45.     }while(AnswerWord.size() != wordcompare(AnswerWord, InputWord));
  46.     cout << "You Won!" << endl;
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement