Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void comes_before(string wrd1, string wrd2)
- {
- cout << "\"" << wrd1 << "\"" << " comes before \"" << wrd2 << "\".\n";
- }
- void comes_after(string wrd1, string wrd2)
- {
- cout << "\"" << wrd1 << "\"" << " comes after \"" << wrd2 << "\".\n";
- }
- void str_compare(string word1, string word2)
- {
- if (word1 == word2)
- {
- cout << "Words are exactly the same.\n";
- }
- else if (word1 > word2)
- {
- comes_after(word1, word2);
- }
- else if(word1 < word2)
- {
- comes_before(word1, word2);
- }
- }
- int main()
- {
- string s1, s2;
- cout << "== String Compare ==\n";
- cout << "Enter a word\n";
- cin >> s1;
- cout << "Enter another word\n";
- cin >> s2;
- str_compare(s1, s2);
- return 0;
- }
Add Comment
Please, Sign In to add comment