purifier wrote:
The problem is to write a program in 'C' to find the greatest
of 2 given numbers... Easy? huh
here's the catch
do not use 'if' or any conditional statements
if u want it to be a little more tougher you can use the if but
this time no relational operators or any of the predefined
functions....
Can someone please help me solve the problem....
I read a similar (but more restricted) question very recently
in another forum.
The following uses strtol() to convert arguments on the command
line, and printf() to output the maximum. Otherwise, it doesn't
use any conditional, logical, equality or relational operators,
nor does it use any selection or iteration statements.
Not sure if Google will mangle this...
% type max2.c
typedef unsigned long q1;int printf(const char*,...);long
strtol(const char*,char**,in t);q1 q2(q1 q3,q1 q4,q1 q5,q1
q6){return(q5-q6)*(((((q3-q4)&(q4-q3) )+2)/(((q3-q4)&(q4-
q3))+1))-1)+q6;}q1 q7(long q8){return q2(q8,0,q2(q8/2,0,1
,0),0);}q1 q9(long q8){return q2(q8,-1,q2(q8/2,-1,1,q2(q8
/2,0,1,0) ),0);}q1 q10(long);q1 q11(long q8){return 0;}q1
q12(long q8){return 1;}q1 q13(long q8){return q10(q8/2);}
q1 q14(long q8){q1(*q15[])(long)={q12,q1 3};return q15[q2(
q9(q8),1,0,1)](q8);}q1 q10(long q8){q1(*q15[])(long)={q11
,q14};return q15[ q2(q7(q8),1,0 ,1)](q8);}q1 q17(long q3,
long q4){return q2(q10( q3),1,q2(q10(q4 ),1,q10(q3-q4),1),
q2(q10(q4),1 ,0,q10(q3-q4 )));}long q18(long q3,long q4){
return q3;}long q19(long q3,long q4){return q4;}long q20(
long q3,long q4){long(*q15[])(long,long)={q 19,q18};return
q15[q2(q17(q3,q4),1 ,0,1)](q3,q4);}long q21(const char*q2)
{return strtol(q2,0,10) ;}int q22(char **q23){printf(" %ld"
"\n",q20(q21(q2 3[1]),q21(q23[2])));return 0;}int q24(char
**q23){return 0;}int main(int q25,char**q23){ int(*q15[])(
char**)={q24,q2 2};return q15[q2(q25,3,1,0)](q23);}
% gcc -ansi -pedantic max2.c -o max2.exe
% max2 -5 42
42
%
--
Peter