Server IP : 172.16.15.8 / Your IP : 18.191.81.46 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/grpatillo/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
/* Author: R.P. Patillo Instructor: Dr. Ames Due Date: Oct. 23, 2008 Complilation: g++ WFFcatcher.cpp -o WFFcatcher.out Execution: ./WFFcatcher.out */ #include <iostream> using namespace std; //---------------------- // WFF Catcher //---------------------- bool WFFcatch() { char ch = ' '; char prevch1 = ' '; char prevch2 = ' '; bool WFF = true; if(WFF) { cin.get(ch); if(ch == 'p' || ch == 'q' || ch == 'r' || ch == 's') { if(prevch1 == 'p' || prevch1 == 'q' || prevch1 == 'r' || prevch1 == 's' || prevch1 == ' ') { if(prevch2 == 'C' || prevch2 == 'A' || prevch2 == 'K' || prevch2 == 'E') return WFFcatch(); else { return false; } } else if(prevch1 == 'N') return WFFcatch(); else if(prevch1 == 'C' || prevch1 == 'A' || prevch1 == 'K' || prevch1 == 'E') { prevch2 = prevch1; ch = prevch1; cout << "*" << ch << "*" << prevch1 << "*" << prevch2; return WFFcatch(); } else if(ch == '\n') { if(prevch1 == 'p' || prevch1 == 'q' || prevch1 == 'r' || prevch1 == 's') return true; else { return false; WFF = false; } } else ch = prevch1; cout << ch << "***" << prevch1; } else if(ch == 'N') { ch = prevch1; return WFFcatch(); } else if(ch == 'C' || ch == 'A' || ch == 'K' || ch == 'E') { ch = prevch1; cout << ch << "******" << prevch1; return WFFcatch(); } else return false; WFF = false; } else if(ch == '\n') { if(prevch1 == 'p' || prevch1 == 'q' || prevch1 == 'r' || prevch1 == 's') return true; else { return false; WFF = false; } } } //---------------------------------------------------- int main () { char ch, prevch1, prevch2; cout << "Enter a well-formed formula: "; cin.get(ch); ch = prevch1; cout << prevch1; WFFcatch(); if (WFFcatch() == true) cout << "well formed" << endl; else if(WFFcatch() == false) cout << "error" << endl; return 0; }