| 1 |
#include <stdio.h> |
| 2 |
#include <math.h> |
| 3 |
|
| 4 |
int months[]={0, 31, 28, 31, 30, 31, 30, |
| 5 |
31, 31, 30, 31, 30, 31}; |
| 6 |
char weekdays[7][15]={"Sunday", "Monday", "Tuesday", "Wednesday", |
| 7 |
"Thursday", "Friday", "Saturday"}; |
| 8 |
|
| 9 |
/* this program calculates the latidude |
| 10 |
where polar day begins/ends */ |
| 11 |
void main() |
| 12 |
{ |
| 13 |
int day=24, month=6, weekday=2; |
| 14 |
double angle=0; |
| 15 |
double latitude; |
| 16 |
|
| 17 |
do |
| 18 |
{ |
| 19 |
latitude=atan(tan((23+27.0/60)*M_PI/180)*cos(angle))*180/M_PI; |
| 20 |
latitude=(latitude>0)? 90-latitude : -90-latitude; |
| 21 |
printf("%2d.%02d %12s : %d %02d'\n", day, month, |
| 22 |
weekdays[weekday], (int)latitude, |
| 23 |
(int)fabs((latitude-(int)latitude)*60)); |
| 24 |
if (weekday==0) |
| 25 |
printf("\n"); |
| 26 |
|
| 27 |
angle+=2*M_PI/365; |
| 28 |
day++; |
| 29 |
if (day>months[month]) |
| 30 |
{ |
| 31 |
day=1; |
| 32 |
month++; |
| 33 |
if (month>12) |
| 34 |
month=1; |
| 35 |
} |
| 36 |
if (++weekday>6) |
| 37 |
weekday=0; |
| 38 |
} while (month!=1); |
| 39 |
} |