Monday, March 8, 2010

Comming along

Just finished Calculus, and now I am taking Discrete Mathmatics. Sounds like something you could get arrested for right? It actually a pretty cool class where you solve logic based math puzzles, and put them into C++ form. First ILab had me make a C++ console app that ran through a truth table. There were two problems that were kinda like this:


A says B is lying
B says A is telling the truth

User put in input whether or not A and Bare telling the truth using "T" or "F".

They way i checked for consistancy though could of been more effecient though:

//Checking for true and false values. Probably not the most efficient way
if (p == "T" && q == "T")
{
varA = "FALSE";
varB = "FALSE";
}
if (p == "T" && q == "F")
{
varA = "TRUE";
varB = "FALSE";
}
if (p == "F" && q == "T")
{
varA = "TRUE";
varB = "TRUE";
}
if (p == "F" && q == "F")
{
varA = "FALSE";
varB = "FALSE";
}

But it works!

No comments: