User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 402,624 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,182 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1733 | Replies: 13
Reply
Join Date: Aug 2005
Posts: 595
Reputation: SpS is on a distinguished road 
Rep Power: 5
Solved Threads: 30
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

substitue of comparison operators

  #1  
Sep 25th, 2005
Can we find the smallest of three integers, without using any of the comparison operators....logic please
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: London
Posts: 164
Reputation: Stoned_coder is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Stoned_coder Stoned_coder is offline Offline
Junior Poster

Re: substitue of comparison operators

  #2  
Sep 25th, 2005
int a=rand();
int b=rand();
int c=rand();
std::vector<int> vec;
vec.push_back(a);
vec.push_back(b);
vec.push_back(c);
std::cout<< *std::min_element(vec.begin(),vec.end())<<std::endl;
not a comparison operator in sight
Reply With Quote  
Join Date: Sep 2004
Posts: 6,069
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 419
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: substitue of comparison operators

  #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.
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
Reply With Quote  
Join Date: Aug 2005
Posts: 1,025
Reputation: Ene Uran is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 64
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Veteran Poster

Solution Re: substitue of comparison operators

  #4  
Sep 25th, 2005
Originally Posted by Stoned_coder
int a=rand();
int b=rand();
int c=rand();
std::vector<int> vec;
vec.push_back(a);
vec.push_back(b);
vec.push_back(c);
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  
Join Date: Jul 2005
Location: France
Posts: 980
Reputation: bumsfeld is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 43
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Posting Shark

Solution Re: substitue of comparison operators

  #5  
Sep 25th, 2005
Silly logic indeed.
Reply With Quote  
Join Date: Aug 2005
Posts: 595
Reputation: SpS is on a distinguished road 
Rep Power: 5
Solved Threads: 30
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: substitue of comparison operators

  #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  
Join Date: Sep 2004
Posts: 6,069
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 419
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: substitue of comparison operators

  #7  
Sep 25th, 2005
>i am just trying to solve some c - puzzles
Then why are you asking us what the answers are?
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
Reply With Quote  
Join Date: Aug 2005
Location: Oklahoma
Posts: 902
Reputation: chrisbliss18 is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 21
chrisbliss18's Avatar
chrisbliss18 chrisbliss18 is offline Offline
Posting Shark

Re: substitue of comparison operators

  #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  
Join Date: Aug 2005
Posts: 595
Reputation: SpS is on a distinguished road 
Rep Power: 5
Solved Threads: 30
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: substitue of comparison operators

  #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  
Join Date: Jun 2005
Location: Troy
Posts: 1,277
Reputation: Rashakil Fol has a spectacular aura about Rashakil Fol has a spectacular aura about 
Rep Power: 7
Solved Threads: 36
Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Salamander Man

Re: substitue of comparison operators

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the C++ Forum

All times are GMT -4. The time now is 1:34 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC