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.Created at 2012-01-10 21: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:Created at 2012-01-10 21:30:40 Permanent Link: /p/0/ |
Post tags: |
All 2 |
|
Back to Tobary book |
Tobary book - Copyright (C) ZhePlus @ Bit Focus | |
About |