substitue of comparison operators

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

substitue of comparison operators

 
0
  #1
Sep 25th, 2005
Can we find the smallest of three integers, without using any of the comparison operators....logic please
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 164
Reputation: Stoned_coder is an unknown quantity at this point 
Solved Threads: 5
Stoned_coder Stoned_coder is offline Offline
Junior Poster

Re: substitue of comparison operators

 
0
  #2
Sep 25th, 2005
  1. int a=rand();
  2. int b=rand();
  3. int c=rand();
  4. std::vector<int> vec;
  5. vec.push_back(a);
  6. vec.push_back(b);
  7. vec.push_back(c);
  8. std::cout<< *std::min_element(vec.begin(),vec.end())<<std::endl;
not a comparison operator in sight
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,858
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: substitue of comparison operators

 
0
  #3
Sep 25th, 2005
>Can we find the smallest of three integers, without using any of the comparison operators....logic please
Can we find out why you're interested in such a silly problem? Logic please.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,546
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 174
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: substitue of comparison operators

 
0
  #4
Sep 25th, 2005
Originally Posted by Stoned_coder
  1. int a=rand();
  2. int b=rand();
  3. int c=rand();
  4. std::vector<int> vec;
  5. vec.push_back(a);
  6. vec.push_back(b);
  7. vec.push_back(c);
  8. std::cout<< *std::min_element(vec.begin(),vec.end())<<std::endl;
not a comparison operator in sight
However, there is a comparison operator out of sight!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: substitue of comparison operators

 
0
  #5
Sep 25th, 2005
Silly logic indeed.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: substitue of comparison operators

 
0
  #6
Sep 25th, 2005
Originally Posted by Narue
>Can we find the smallest of three integers, without using any of the comparison operators....logic please
Can we find out why you're interested in such a silly problem? Logic please.
Originally Posted by bumsfeld
silly logic indeed
Hey cmon guys...i don't have a leg-pull function as friend.....i am just trying to solve some c - puzzles
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,858
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: substitue of comparison operators

 
0
  #7
Sep 25th, 2005
>i am just trying to solve some c - puzzles
Then why are you asking us what the answers are?
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 902
Reputation: chrisbliss18 is an unknown quantity at this point 
Solved Threads: 23
chrisbliss18's Avatar
chrisbliss18 chrisbliss18 is offline Offline
Posting Shark

Re: substitue of comparison operators

 
0
  #8
Sep 26th, 2005
It's funny, but almost all of sunnypalsingh's questions sound like questions that an idiot teacher would ask. Knowing the answer to such questions doesn't help anyone understand programming and definately doesn't help a programmer develop good technique.
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: substitue of comparison operators

 
0
  #9
Sep 26th, 2005
Originally Posted by Narue
Then why are you asking us what the answers are?
bcoz i was not able to do it

and don't reply if u don't want to..plz
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,055
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: substitue of comparison operators

 
0
  #10
Sep 26th, 2005
Originally Posted by chrisbliss18
It's funny, but almost all of sunnypalsingh's questions sound like questions that an idiot teacher would ask. Knowing the answer to such questions doesn't help anyone understand programming and definately doesn't help a programmer develop good technique.
Actually, I have had this sort of question, and it was appropriate for the class I was taking. It doesn't help anyone understand programming, but it helps some understand how integers are represented, or why they are represented the way that they are.

Originally Posted by sunnypalsingh
bcoz i was not able to do it
Really? How long did you try? If you tried again for the same length of time, would you necessarily not be able to solve the problem then? If you can't be creative enough and effortful enough to solve this problem, how will you ever be creative enough to come up with solutions to harder problems?

The benefit of this problem is that in solving it, you'll improve your creativity. Yes, creativity is learned. Well, conditioned, maybe. At least the problem-solving kind of creativity is. Anyway, this skill is important to your ability in the arena of computer programming, and you might as well get good at it now, or else you'll suck forever.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 2719 | Replies: 13
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC