age

 1 #include<iostream>
 2 #include<math.h>
 3 #define pi 3.14
 4 using namespace std;
 5 int main()
 6 {
 7     int computeday(int y[],int m[],int day[]);
 8     double compute_physiological_index(int d);
 9     double compute_emotional_index(int d);
10     double compute_mentality_index(int d);
11     int year[2];
12     int month[2];
13     int day[2];
14     int d;
15     cout << "Please input your birthday:" << endl;
16     cin >> year[0] >> month[0] >> day[0];
17     cout << "Please input today:" << endl;
18     cin >> year[1] >> month[1] >> day[1];
19     d = computeday(year,month,day);
20     cout << compute_physiological_index(d) << endl;
21     cout << compute_emotional_index(d) << endl;
22     cout << compute_mentality_index(d) << endl;
23     return 0;
24 }
25 int computeday(int y[],int m[],int day[])
26 {
27     int d=0;
28     int x[12]={31,28,31,30,31,30,31,31,30,31,30,31};
29     if( ( ( y[0] % 400 == 0 ) || ( y[0] % 100 != 0) && ( y[0] % 4 == 0 ) ) && m[0] <= 2)
30     {
31         if(m[0] == 2)
32             d += 356 - day[0] - 31; 
33         else
34             d += 356 - day[0];
35     }
36     else
37     {
38         if(y[0] < y[1])
39         {
40             for( ; m[0] <= 12 ; ++ m[0] )
41                 d += x[m[0]-1];
42         }
43     }     
44     for(y[0] += 1;y[0] < y[1]; y[0] ++)
45     {
46         m[0] = 1;
47         x[1] = 28;
48         if( ( y[0] % 400 == 0 ) || ( y[0] % 100 != 0) && ( y[0] % 4 == 0 ) )
49             x[1] += 1;
50         for(;m[0] < 12;m[0] ++)
51             d += x[m[0]-1];
52     }
53     for(;m[0] < m[1];m[0] ++)
54         d +=x[m[0]-1];
55     d += day[1];
56     d = d - day[0] + 1;
57     cout<<d<<endl;
58     return d;
59 }
60 double compute_physiological_index(int d)
61 {
62     return (sin(d*2*pi/28));
63 }
64 double compute_emotional_index(int d)
65 {
66     return (sin(d*2*pi/23));
67 }
68 double compute_mentality_index(int d)
69 {
70     return (sin(d*2*pi/33));
71 }            

 

posted on 2013-12-26 16:46  了发发  阅读(145)  评论(0)    收藏  举报

导航