Use
*a
instead ofa[0]
for accessing the first element of an array.Relational operators (
!=
,>
, etc.) give0
or1
. Use this with arithmetic operators to give different offsets depending on whether the condition is true or false:a[1+2*(i<3)]
would accessa[1]
ifi >= 3
anda[3]
otherwise.
↧
Answer by es1024 for Tips for golfing in C
↧