func is_leap_year(year)
return (year MOD 4) XOR (year MOD 100) XOR (year MOD 400)
MOD
is modulo, and XOR
is exclusive or.
At Wikipedia we may see a straightforward way to tell whether a year is leap or not. Well here is a more "compact" way (pseudocode)
func is_leap_year(year) MOD is modulo, and XOR is exclusive or.Posted at Jan 10 2012 - 12:31:39 Permanent Link: /p/1 |
Post tags: |
We are going to calculate points of intersections for 2 circels, given their centers and radiuses on a 2D plane. Say, we will implement the following C function
int intersect(struct circle_t const circles[], struct point_t intersections[]); where point_t and circle_t arestruct point_t { intersect takes 2 circles as parameter, returns the number of points of intersection, and the details of the points will be put in parameter intersection . Since 2 circles may have up to 2 points of intersection, we may call that function in following way:Posted at Jan 10 2012 - 12:30:40 Permanent Link: /p/0 |
Post tags: |
Back to Bit Focus Blog | |
NijiPress - Copyright (C) Neuron Teckid @ Bit Focus | |
About this site |