Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.222.56.251
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_proof2.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
		{
			return WffCatch();
		}
		else if(ch == 'C' || ch== 'A' || ch == 'K' || ch == 'E')  // rule 3
		{
			bool t1, t2;
			t1=WffCatch();
			t2=WffCatch();
		
			return t1 && t2;
		}
		else 	
			return false;
	}
}



//---------------------------------------------------------------
// client code
//----------------------------------------------------------------
int main ()
{
	char ch;

	cout << "Enter a string:\n";

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

Stv3n404 - 2023