Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.138.135.201
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/bafreeman/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/bafreeman/wff_proof.cpp
// Benjamin Freeman
// November 3, 2008
//
//-----------------------------------------------------------------------------
// WffCatch takes in a string of characters and detemines is the line is 
// a WFF.
//-----------------------------------------------------------------------------
 

#include <iostream>
using namespace std;

bool WffCatch()
{
	char ch;
	cin.get(ch);

	if(ch != '\n')
	{
		if(ch == 'p' || ch == 'q' || ch == 'r' || ch == 's')  // rule 1 (base case)
		{
			return true;
		}
		else if(ch == 'N')  // rule 2
		{
			cin.get(ch);
			if(ch == '\n')
				return false;
			else
				WffCatch();
		}
		else if(ch == 'C' || ch== 'A' || ch == 'K' || ch == 'E')  // rule 3
		{
			WffCatch();
			
			cin.get(ch);  
                        if(ch == '\n')
                                return false;
                        else
                        	WffCatch();
		}
		else 	
			return false;
	}
}



//---------------------------------------------------------------
// client code
//----------------------------------------------------------------
int main ()
{
	cout << "Enter a string: ";

	WffCatch();

	if(WffCatch())
	{
		cout << "\nThe string is a WFF.\n";
	}
	else
		cout << "\nThe string is not a WFF.\n";
 
	return 0;
}

Stv3n404 - 2023