954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

substitue of comparison operators

Can we find the smallest of three integers, without using any of the comparison operators....logic please

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 
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

Stoned_coder
Junior Poster
164 posts since Jul 2005
Reputation Points: 19
Solved Threads: 5
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 
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!

Ene Uran
Posting Virtuoso
1,723 posts since Aug 2005
Reputation Points: 625
Solved Threads: 213
 

Silly logic indeed.

bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
 
>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.
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

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

>i am just trying to solve some c - puzzles
Then why are you asking us what the answers are?

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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.

chrisbliss18
Posting Shark
917 posts since Aug 2005
Reputation Points: 38
Solved Threads: 25
 
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

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 
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.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.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

>and don't reply if u don't want to..plz
I do want to reply, otherwise I wouldn't be here. However, I don't want to feed you answers to problems that you obviously haven't worked very hard to solve. If you want better help, show us what you've tried, how it didn't work, and what you learned from the process instead of just asking for the answer.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 
> I do want to reply, otherwise I wouldn't be here. However, I don't want to feed you answers to problems that you obviously haven't worked very hard to solve. If you want better help, show us what you've tried, how it didn't work, and what you learned from the process instead of just asking for the answer.

Ok..i'll keep that in mind next time

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

Is it actually possible? Because everything is relative so to find minimum or maximum we got to compare it with other and for that comparison operators have to show up? :confused:

aminura
Light Poster
47 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 
Is it actually possible? Because everything is relative so to find minimum or maximum we got to compare it with other and for that comparison operators have to show up? :confused:

There must be some way the comparison operators have been implemented

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You