Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "std_lib_facilities.h"
- // Chapter 6 Exercise 6
- /*
- English grammar
- */
- bool is_noun(string str){
- vector<string>noun{"birds", "fish", "C++"};
- for (auto i = 0; i < noun.size(); ++i) {
- if (str == noun[i])
- return true;
- }
- return false;
- }
- bool is_verbs(string str) {
- vector<string>verbs{"rules", "fly", "swim"};
- for (auto i = 0; i < verbs.size(); ++i) {
- if (str == verbs[i])
- return true;
- }
- return false;
- }
- bool is_conjuction(string str) {
- vector<string>conjuction{"but", "or", "and"};
- for (auto i = 0; i < conjuction.size(); ++i) {
- if (str == conjuction[i])
- return true;
- }
- return false;
- }
- bool is_pretex(string str) {
- vector<string>pretex{"the"};
- for (auto i = 0; i < pretex.size(); ++i) {
- if (str == pretex[i])
- return true;
- }
- return false;
- }
- bool is_point(string str) {
- string poin = "."s;
- if (str == poin) {
- return true;
- }
- return false;
- }
- bool senteces() {
- string pr, no, verb, conj, pr1, no1, verb1, t4k;
- cin >> pr >> no >> verb >> conj >> pr1 >> no1 >> verb1 >> t4k;
- if (!is_pretex(pr))
- return false;
- if (!is_noun(no))
- return false;
- if (!is_verbs(verb))
- return false;
- if (!is_conjuction(conj))
- return false;
- if (!is_pretex(pr1))
- return false;
- if (!is_noun(no1))
- return false;
- if (!is_verbs(verb1))
- return false;
- if (is_point(t4k))
- return true;
- }
- int main() {
- bool a = senteces();
- if (a) {
- std::cout << "OK";
- }
- else
- std::cout << "ERROR";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement