-
June 26th, 2002, 11:52 PM
#1
c++ challange
Thought id give you programers a challeng, Ill post the program prob tommorow.
De Morgan's Laws can sometimes make it more convenient for us to express a logical expression. These laws state that the expression !(condition1 && condition2) is logically equivalent to the expression (!condition1 ||!condition2). Also the expression !(condition1 || condition2) is logically equivalent to the (!condition1 && !condition2). Use De Morgan's Laws to write equivalent expressions for each of the following then write a program to show that both the original expressions and the new expression in each case are equivalent:
a) !( x < 5) && !( y >= 7 )
b) !( a == b) || !(g != 5)
c) !( ( x <= 8 ) && ( y > 4) )
d) !( (i > 4 ) || ( j <= 6 ))
-
June 27th, 2002, 12:03 AM
#2
I think these are right (it's been a while since I've used DeMorgan's Law)
a) !(x < 5) && !(y >= 7) = !((x < 5) || (y >= 7))
b) !(a == b) || !(g != 5) = !((a == b) && (g != 5))
c) !((x <= 8) && (y > 4)) = !(x <= 8) || !(y > 4)
d) !((i > 4) || (j <= 6)) = !(i > 4) && !(j <= 6)
Sorry, but I don't feel like writing a program right now... Nice idea, though!
AJ
-
June 27th, 2002, 12:05 AM
#3
a) !( x < 5) && !( y >= 7 )
b) !( a == b) || !(g != 5)
c) !( ( x <= 8 ) && ( y > 4) )
d) !( (i > 4 ) || ( j <= 6 ))
a)
!(x<5) && !(y>=7)
!((x<5)||(y>=7))
#include <iostream.h>
int main()
{
int x;
if (!(x<5) && !(y>=7))!=(!((x<5)||(y>=7)))
{
cout<<"That's not Right!";
}
else
{
cout<<"You are correct!";
}
return 0;
}
I don't have a compiler at work. Does that prog look like it will work? I think it should, but then again i'm still learning c++. I'm not even gunna attempt any more unless this one works. heh
x
-
June 27th, 2002, 01:11 AM
#4
a) !( x < 5) && !( y >= 7 ) == !( x < 5 || y >= 7 )
b) !( a == b) || !(g != 5) == !( a == b && g != 5 )
c) !( ( x <= 8 ) && ( y > 4) ) == !( x <= 8 ) || !( y > 4 )
d) !( (i > 4 ) || ( j <= 6 )) == !( i > 4 ) && !( j <= 6 )
#include <iostream>
using namespace std ;
void main ()
{
for( x=0, y=0; x=-1; x++,y++)
{
if ( (!( x < 5) && !( y >= 7 )) == (!( x < 5 || y >= 7 )) cout << "bOOOOOOGA\a\t" ;
else cerr << "blAAAAARRRGH" << endl ;
}
}
Hmm...theres something a little peculiar here. Oh i see what it is! the sentence is talking about itself! do you see that? what do you mean? sentences can\'t talk! No, but they REFER to things, and this one refers directly-unambigeously-unmistakably-to the very sentence which it is!
-
July 1st, 2002, 02:05 PM
#5
-
July 1st, 2002, 02:32 PM
#6
Junior Member
The answers simplified as far as they can go are:
a) x >= 5 && y < 7
b) a != b || g == 5
c) x> 8 || y <= 4
d) i <= 4 && j > 6
as for the program, i'm too tired at the moment to write it up...
Chaoswraith
-
July 1st, 2002, 04:12 PM
#7
Heh, for a second I just felt like I was back in a first year CS maths course again!
Don't do that again!
Ammo
Credit travels up, blame travels down -- The Boss
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|