. - 3GL   - 4GL   5GL  

3GL

2000 ( Y2K), . , , 2000 . , , 29 . , , .


"" calendae (" ") calendarium (" "). .

, , . 21 23 . . 365 5 48 46 (365,2422 , 24 ).

, , . , , 12 29->30->29->30-> ... . 354 .

IV . . . 365 12 30 . 5 .

, 47 . . . 46- 432 . 3 365 , 1 . , 365,25 , .

1500 10 . . 1582 XIII , 200300 . , , 1918 ( 31 14 , ). " ", " ". . 4 1582 15 . . , , 400. 26 . , 1 4860 .

. ( ), , . , , . 1.

XVI . (12 1 4713 , 4712) , . JD ( ) , , 0,0 0,99999 . 12 .

:

1 4712 . .. 12 JD = 0.00000

2 4712 . .. 12 JD = 1.00000

3 4712 . .. 18 JD = 2.25000

1 1900 . 12 JD = 2415021.0

22 1941 . 4 JD = 2430167.66667

9 1945 . 12 JD = 2431585.0

1 1999 . 12 JD = 2451180.0

1 2000 . 12 JD = 2451545.0

, . Borland C++ Builder Delphi TDateTime, (double). , 30 1899 , . .

. 8 double, "YYYY/MM/DD HH:MM:SS" 20 . JD ( long), 4 . , 7 (2 1 ). MS-DOS . Y , Y-1980 [0,119], 4 , 5 . 32 . , . , .

. , , , . , JD .

. , , , . , , . , . . , .


, . . JDI -60 (Fliegel H. F., Van Flandern . . A Machine Algorithm for Processing Calender Dates (algorithm 657). Communications of the ACM, 1968). (Spaeth H. Ausgewaehlte Operations Research-Algorithmen in FORTRAN. Wien, 1975) JDI. JD2, , . " " (.: , 1988). , . , . .

JD1

JDI (Y), () () 12 . JDI JDI.C, . .

long JDI(int Y,int M,int D) {

long q,j;

j=(M-14)/12;

q=Y+j+4800;

return D-32075L+1461*q/4+367L*(M-2-12*j)/12-3*((q+100)/100) /4; }

, JDI 15.10.1582. . , , .

JD2

( , , -

), ( 1 12) = D.T (D , 0,00000 0,99999, ). , int - .

> 2, y = Y m = M, = Y - 1 m = + 12. 15.10.1582, :

= int(/100)

= 2 - + int(/4)

, = . :

= int(365.25*) > 0

= int(365.25 * - 0.75) < 0

JD :

JD = + int (30. 6001 * (m+D) + DT + 1720994.5 +

, JD2 , 1.01.4713 . . ( Y = -4712, = 1, = 1.5) . 12 . .

JD3

JD3, , . :

double JD3(int Y,int M,double DT) {

return 367.0*Y-floor(7.0*(Y+floor((M+9.)/12.))/4.)+

floor(275.0*M/9.)+DT+1721013.5; }

JD, 101,1600 (JD3 = 2305445.0), (JD2 = = 2305448.0) 3 . , JD3 1.03.1900. , JD3 JD2, 29.02.2100.

,

9.01.

JD, (Y), (), , ( , , ). , .

1 ()

, . JD2. , JD , .

9_01.bas

DECLARE FUNCTION JD! (Y%, M%, DT!)

REM

REM ( )

CLS

INPUT " : ",Y%

INPUT " : ",%

INPUT " : ",DT

PRINT USING "##### ### ###.#";Y%;M%;DT;

jdl=JD(Y%,M%,DT)

PRINT USING " JD =#########.#####";jdl

END

FUNCTION JD(Y%,M%,DT)

' Y - [-4713,9999]

' - [1,12]

' DT - [1,31]

' DT - ,

' [.0,.99999]

' -

' JD - ,

' 1 4713

' JD - ,

' 12 JD

b%=0: yy%=Y%: mm%=M%

IF M%<3 THEN %=%-1: mm%=mm%+12

%=% \ 100

IF Y%+M% / 1001+DT/10000 > 1582.10151 THEN

b%=b%+2-a%+(a% \ 4} END IF

c&=INT(365.25*yy%)

IF yy%<0 THEN c&=INT(365.25*yy%-.75)

JD=c&+INT(30.6001*(mm%+l))+DT+1720994.5#+b%

END FUNCTION

9_01.

#include <stdio.h>

#include <conio.h>

#include <math.h>

double JD (int Y,int M,double DT);

main() {

int Y,M,day;

double DT,jd;

clrscr();

printf("\n : ");

scanf("%d",&Y);

printf("\n : ");

scanf("%d",SM);

printf("\n : ");

scanf("%lf",&DT);

jd=JD(Y,M,DT);

printf("\n JD =%15.5f",jd);

getch();

}

/*----------------------------------------* /

/*----------------------------------------* /

double JD(int Y,int M,double DT)

/*******************************************/

/* */

/* ( ) */

/* Y - [-4713,9999] */

/* - [1,12] */

/* DT - [1,31] */

/* DT - , */

/* [.0,.99999] */

/* - */

/* JD - , */

/* 1 4713 */

/* JD - , */

/* 12 JD */

{

int a,b=0,m,y;

long ;

y=Y;

m=M;

if (M<3) { y--; m += 12; }

a=y/100;

if(Y+M/100.+DT/10000 > 1582.1015)

b += 2-a+(int)(a/4.);

c=365.25*y;

if(y<0)c=365.25*y-0.75;

return c+(long)(30.6001*(m+1))+DT+1720994.5+b; }

9_01.pas

program gd_t6_jd;

uses Crt;

var

Y,M,day:integer; DT,jdl:double;

function JD(Y,M:integer;DT:double):double;

{ }

{ ( ) }

{ Y - [-4713,9999] }

{ - [1,12] }

{ DT - [1,31] }

{ DT - , }

{ [.0,.99999] }

{ - }

{ JD - , }

( 1 4713 }

{ JD - , }

{ 12 JD }

var

a,b,mm,yy:integer;

:longint; begin

b:=0;

yy:=Y;

mm:=M;

if M<3 then begin yy:=yy-l;

mm:=mm+12;

end;

a:=yy div 100;

if (Y+M/100.+DT/10000)>1582.1015 then b:=b+2-a+(a div 4);

c:=trunc(365.25*yy);

if yy<0 then c:=trunc(365.25*yy-0.75) ;

JD:=c+trunc(30.6001*(mm+1))+DT+1720994.5+b;

end;

begin

clrscr;

write(' : ');

readln(Y);

write(' : ');

readln(M);

write(' : ');

readln(DT);

write(Y:4,M:3, ' ',DT:3:1);

jdl:=JD(Y,M,DT);

writelnC JD =', jdl:15:5) ;

readln; end.

9.02.

GD, , JD.

1 ()

, . . .

JD+0.5 z , F . z > 2299161, :

a=int((Z-1867216.25)/36524.25) A=Z+l+a-int(a/4) z < 2299161

A=Z

=+1524

C=int((B-122.1)/365.25

D=int(365.25*C)

E=int((B-D)/30.6001)

DT=B-D-int(30.6001*E)

M=-1, E<13.5

M=-13, >13.5

Y=C-4716, >2.5

Y=C-4715, <2.5

9_02.bas

DECLARE SUB GD(jd!,y%,m%,DT!)

REM JD

- Y (), (),

REM DT ( ,

CLS

INPUT " : ",jd

GD jd,y%,m%,DT

PRINT USING " = ##### = ## = ####";y%;m%;DT

END

SUB GD(jd,y%,m%,DT)

'

' jd.

' % -

' m% -

' dt - ( ) ( )

DIM A AS LONG, AS LONG, AS LONG, D AS LONG, Z AS LONG

DIM aa AS LONG, E AS INTEGER, F AS DOUBLE

Z=INT(jd+.5)

F=jd+.5-Z

A=Z

IF Z>=2299161 THEN

aa=INT((Z-1867216.25#)/36524.25) A=A+l+aa-(aa\4)

END IF B=A+1524

C=INT((B-122.1)/365.25) D=INT(365.25*C) E=INT((B-D)/30.6001)

DT=B-D-INT(30.6001*E)+F

IF E<13.5 THEN m%=E-l

ELSE m%=E-13

IF m%>2.5 THEN y%=C-4716

ELSE y%=C-4715

END SUB

9_02.

#include <stdio.h>

#include <conio.h>

void GD(double jd,int *y,int *m,double *dt);

main () (

int Y,M;

double DT,jd;

clrscr () ;

printf("\n : ");

scanf("%lf",&jd);

GD(jd, &Y, &M, &DT) ;

printf("\n l=%d =%d =%-15.51f",Y,M,DT);

getch();

}

/*--------------------------------------*/

void GD(double jd,int *y,int *m,double *dt)

/* */

/* jd */

/* - , m - */

/* dt - ( ) */

/* ( ) */

/**************************************/

{

long a,A,B,C,D,E, Z;

double F;

Z=jd+0.5;

F=jd+0.5-Z; A=Z;

if(Z>=2299161)

{

a=(Z-1867216.25)/36524.25;

A += l+a-a/4; }

B=A+1524;

C=(B-122.1)/365.25;

D=365.25*C; E=(B-D)/30.6001;

*dt=B-D-(int)(30.6001*E)+F;

if(E<13.5) *m=E-l;

else *m=E-13;

if(*m>2.5) *y=C-4716;

else *y=C-4715; }

9_02.pas

program jd_to_gd;

{ JD - Y (), (), DT ( , }

uses crt; var

Y,M:integer;

DT,jd:double;

procedure GD(jd:double;

var y,m:integer; var dtrdouble);

{ }

{ jd }

{ - , m - }

{ dt - ( ) }

( ( ) }

var

aa,A,B,C,D,E,Z:longint;

F:double; begin

Z:=trunc(jd+0.5);

F:=jd+0.5-Z;

A:=Z;

if Z>=2299161 then begin

aa:=trunc((Z-1867216.25)/36524.25);

A:=A+l+aa-(aa div 4);

end;

B:=A+1524;

C:=trunc( (B-122.D/365.25) ;

D:=trunc(365.25*C);

E:=trunc((B-D)/30.6001);

dt:=B-D-trunc(30.6001*E)+F;

if E<13.5 then m:=E-l

else m:=E-13;

if m>2.5 then y:=C-4716

else y:=C-4715;

end;

begin

clrscr;

write(' : ');

readln(jd);

GD(jd,Y,M,DT);

writeln(' = ',Y:4,' = ',M:2,' = ',DT:4:1);

readln; end.

9.03.

dif_time, .

1 ()

. , , .

9_03.bas

DECLARE FUNCTION JD! (Y%, M%, DT!)

DECLARE FUNCTION DifTime! (Yl%, Ml%, DTI!, Y2%, M2%, DT2!)

REM

REM : (Y1,M1,DT1) (Y2,M2,DT2)

CLS

INPUT " : ",Y1%

INPUT " : ",1%

INPUT " : ",DT1

INPUT " : ",Y2%

INPUT " : ",2%

INPUT " : ",DT2

PRINT " =",DifTime(Y1%,M1%,DTI,Y2%,M2%,DT2)

END

FUNCTION DifTime (Y1%,M1%,DTI,Y2%,M2%,DT2)

'

'

' Y1,Y2 - 1,2 -

' DTI, DT2 -

' DTI, DT2 -

jdl=JD(Y1%,M1%,DT1)

jd2=JD(Y2%,M2%,DT2)

DifTime=ABS(jdl-jd2) END FUNCTION

FUNCTION JD(Y%,M%,DT)

DIM a AS INTEGER, b AS INTEGER, mm AS INTEGER, yy AS INTEGER

DIM AS LONG

b=0

yy=Y%

mm=M%

IF M%<3 THEN yy=yy-l: mm=mm+12

=\100

IF Y%+M%/100!+DT/10000>1582.1015# THEN

b=b+2-a+a\4 END IF

c=INT(365.25*yy)

IF yy<0 THEN

c=INT(365.25*yy-.75)

JD=c+INT(30.6001*(iran+1))+DT+1720994.5#+b

END FUNCTION

9_03.

#include <stdio.h>

#include <conio.h>

#include <math.h>

double dif_time(int Yl,int Ml,double DTI,

int Y2,int M2,double DT2);

double JD(int ,int M,double DT);

main () {

int Y1,Y2,M1,M2;

double DT1,DT2;

clrscr();

printf("\n : ");

scanf("ld",&Yl);

printf("\n : ");

scanf("%d",&Ml);

printf("\n : ");

scanf("%lf",&DTD;

printf("\n : ");

scanf("%d",SY2);

printf("\n : ");

scanf("%d",&M2);

printf("\n : "};

scanf("%lf",&DT2);

printf("\n = %lf",dif_time(Y1,M1,DTI,Y2,M2,DT2));

getch(); }

/*----------------------------*/

double dif_time(int Yl,int Ml,double DTI, int Y2,int M2, double DT2)

/* */

/* */

/* Y1,Y2 - 1,2 - */

/* DTI, DT2 - */

/* DTI, DT2 - */ /***************************************/

return fabs(JD(Yl,Ml,DTl)-JD(Y2,M2,DT2));

}

/*---------------------------------------------------* /

double JD(int Y,int M, double DT) {

int a,b=0,m,y;

long c;

y=Y;

m=M;

if (M<3) { y--; m += 12; }

a=y/100;

if(Y+M/100.+DT/10000 > 1582.1015)b += 2-a+(int)(a/4.);

c=365.25*y;

if(y<0) c=365.25*y-0.75;

return c+(long) (30.6001* (m+1))+DT+1720994.5+b; }

9_03.pas

program gd_to_jd;

{ : (Y1,M1,DT1) (Y2,M2,DT2) }

uses Crt; var

Yl,Ml,Y2,2:integer;

DTI,DT2:double;

function JD(Y,M:integer;

DT:double):double;

var

a,b,mm,yy:integer;

c:longint;

begin

b:=0;

yy:=Y;

mm:=M;

if M<3 then begin yy:=yy-l;

mm:=mm+12; end;

a:=yy div 100;

if (Y+M/100.+DT/10000)>1582.1015 then b:=b+2-a+(a div 4};

c:=trunc(365.25*yy);

if yy<0 then c:=trunc(365.25*yy-0.75);

JD:=c+trunc(30.6001*(mm+1))+DT+1720994.5+b;

end;

function dif_time(Yl,Ml:integer;

DTI:double;

Y2,M2:integer; DT2:double):double;

{ }

{ }

{ Y1,Y2 - 1,2 - }

{ DTI, DT2 - }

{ DTI, DT2 - } begin

dif_time:=abs(JD(Y1,M1,DT1)-JD(Y2,M2,DT2)) ;

end;

begin

clrscr;

write(' : ');

readln(Yl);

write(' : ');

readln(Ml);

write(' : ');

readln(DTl);

write(' : ');

readln(Y2);

write(' : ');

readln(M2);

write(' : ') ; readln(DT2);

writeln(' = ',dif_time(Y1,M1,DT1,Y2,M2, DT2):10:0); readln; end.

9.04.

week_day, .

1 ()

:

=(JD+1.5) mod 7

, , 1 ( 4712 . .) JD=-0 . 5. 0 , 1 , 2 , ..., 6 .

2 ()

week_dayl , 15.10.1582.

9_04.bas

DECLARE FUNCTION JD!(Y%,M%,DT!)

DECLARE FUNCTION WeekDay!(Y%,M%,D%)

REM

CLS

INPUT " : ",Y%

INPUT " : ",%

INPUT " : ",D%

PRINT " = ";WeekDay(Y%, M%, D%)

END

FUNCTION JD(Y%,M%,DT)

DIM a AS INTEGER, b AS INTEGER, mm AS INTEGER, yy AS INTEGER

DIM AS LONG

b=0

yy=Y%

mm=M%

IF M%<3 THEN yy=yy-l: mm=ram+12

a=yy\100

IF Y%+M%/100!+DT/10000>1582.1015# THEN

b=b+2-a+a\4 END IF

c=INT(365.25*yy)

IF yy<0 THEN c=INT(365.25*yy-.75)

JD=c+INT(30.6001*(mm+1))+DT+1720994.5#+b

END FUNCTION

FUNCTION WeekDay(Y%,M%,D%)

'

' Y -

' - (1 - 12)

' D - (1 - 31)

' :

' 0 - ., 1 - ., 2 - ,...

WeekDay=INT(JD(Y%,M%,D%+1.5)) MOD 7

END FUNCTION

9_04.

#include <stdio.h>

#include <conio.h>

#include <math.h>

int week_day(int Y,int M,int D);

double JD(int Y,int M,double DT);

main() {

int Y,M,D,day;

clrscr();

printf("\n : ") ;

scanf("%d",&Y);

printf("\n : ");

scanf("%d",&M);

printf("\n : ") ;

scanf("%d",&D);

day=week_day (Y, M, D) ,-

printf("\ = %d",day) ;

getch();

}

/*--------------------------------*/

int week_day(int ,int M,int D)

/* */

/* : */

/* 0 - ., 1 - ., 2 - ,... */

/************************************/

{

return (long)(JD(Y,M,(double)D)+1.5) % 7;

}

/*---------------------------------*/

double JD(int Y,int M,double DT) int a,b=0,m,y;

long c;

y=Y;

m=M;

if (M<3) { y--; m += 12; }

a=y/100;

if(Y+M/100.+DT/10000 > 1582.1015) b += 2-a+(int)(a/4.);

c=365.25*y;

if(y<0)c=365.25*y-0.75;

return c+(long)(30.6001*(m+1))+DT+1720994.5+b; }

week_day1.

int week_dayl(int Y, int M, int D)

{

/********************************/

/* */

/* : */

/* 1 - ., 2 - ,..., 7 - */

int q,m;

q=M+10;

m=(M-14)/12+Y;

return ((13*(q-(q/13)*12)-1)/5+D+77+5* (m%100) /4 +

m/400-(m/100)*2)%7; }

9_04.pas

program WeekDay;

{ }

uses Crt;

var

Y,M,D,day:integer;

function JD(Y,M:integer; DT:double):double; var

a,b,mm,yy:integer;

:longint; begin

b:=0;

yy:=Y;

mm:=M;

if M<3 then begin yy:=yy-l;

mm:=mm+12; end;

a:=yy div 100;

if (Y+M/100.+DT/10000)>1582.1015 then b:=b+2-a+(a div 4);

c:=trunc(365.25*yy);

if yy<0 then c:=trunc(365.25*yy-0.75) ;

JD:=c+trunc(30.6001*(mm+l))+DT+1720994.5+b;

end;

function week_day(Y,M,D:integer):integer;

{ }

{ Y - }

{ - (1-12) }

{ D - (1 - 31) }

{ : }

{ 0 - ., 1 - ., 2 - ,... }

begin

week_day:=trunc(JD(Y,M,D+1.5)) mod 7; end;

begin

clrscr;

write(' : ') ;

readln(Y);

write(' : ') ;

readln(M);

write (' : ');

readln(D);

day:=week_day(Y,M,D);

writeln(' = ',day);

readln; end.

9.05.

dat_to_ord, .

1 ()

, . :

N=int(275*M/9)-2*int((+9)/12)+D-30

:

N=int(275*M/9)-int((+9)/12)+D-30

9_05.bas

DECLARE FUNCTION DatToOrd!(y%,M%,D%)

REM

REM ( - , m -, d - )

CLS

INPUT " : ",%

INPUT " : ",%

INPUT " : ",D%

PRINT " = ";

DatToOrd(%,M%,D%)

END

FUNCTION DatToOrd(y%,M%,D%)

DIM a1 AS INTEGER, a2 AS INTEGER

al=(M%+9)\12

a2=INT(275!*M%/9!}-a1+D%

IF (y% MOD 400=0) OR ( (y MOD 4=0) AND (y MOD 100<>0) ) THEN DatToOrd=a2-30

ELSE DatToOrd=a2-al-30

END IF

END FUNCTION

9_05.c

#include <stdio.h>

#include <conio.h>

int dat_to_ord(int y,int m,int d) ;

main() {

int Y,M,D;

clrscr();

printf("\n : ");

scanf("%d",&Y);

printf("\n : ");

scanf("%d",&M);

printf("\n : ");

scanf("%d",&D) ;:

printf("\n = %d", dat_to_ord(Y,M,D));

getch();

}

/*-----------------------------------------*/

int dat_to_ord(int y,int m,int d)

{

int a1,a2;

al=(m+9.0)/12.0;

a2=(275.0*m/9.0)-a1+d-30;

if((y%400==0)||((y%4==0)&&(y%100!=0)))

return a2;

return a2-a1; }

9_05.pas

program ord day;

Crt; var

Y,M,D:integer;

function dat_to_ord(y,m,d:integer):integer; {

( - , m - , d - ) } var

al,a2:integer; begin

al:=(m+9) div 12;

a2:=trunc(275.0*m/9.0)-al+d-30;

if((y mod 400 = 0) OR {(y mod 4=0) AND (y mod 100 <>0))) then dat_to__ord: =a2

else dat_to_ord:=a2-al;

end;

begin

clrscr;

write(' : ');

readln(Y);

write(' : ');

readln(M);

write(' : ');

readln(D);

writeln(' = ', dat_to_ord(Y,M,D));

readln;

end.

9.06.

month_day, (M) (D) (N) .

1 ()

, . , = 1889 = 1523 .

:

B=int((N+A-122.1)/365.25)

C=N+A-int(365.25*B)

E=int(C/30.6001)

M=E-1 <13.5

M=E-13 >13.5

D=C-int(30.6001*E)

9_06.bas

DECLARE SUB MonthDay(Y%,OrdDay%,M%,D%)

R

CLS

INPUT " : ",Y%

INPUT " : ",OrdDay%

MonthDay Y%,OrdDay%,%,D%

PRINT " = ",%;" = ";D%

END

SUB MonthDay(Y%,OrdDay%,M%,D%)

' Y%

' ord_day%

' % -

' D% -

DIM A AS INTEGER, AS INTEGER, AS INTEGER, E AS INTEGER

A=1889

IF (Y% MOD 400=0)OR((Y% MOD 4=0)AND(Y% MOD l00<>0) ) THEN A=1523

B=INT((OrdDay%+A-122.1)/365.25)

C=OrdDay%+A-INT(365.25*B)

E=INT(C/30.6001)

IF E<13.5 THEN M%=E-1 ELSE M%=E-13'

D%=C-INT(30.6001*E)

END SUB

9_06.

#include <stdio.h> ,

#include <conio.h>

#include <math.h>

void month_day(int Y,int ord_day,int *M,int *D);

main() {

int Y,M, D,ord_day;

clrscr();

printf("\n : ");

scanf("%d",&Y);

printf("\n : ");

scanf("%d",&ord_day);

month_day(Y,ord_day,&M, &D);

printf("\n = %d = %d",M,D);

getch();

}

/*-------------------------------------*/

void month_day(int Y,int ord_day,int *M,int *D)

/*************************************/

/* Y */

/* ord_day */

/* - */

/* D - */

/****************************************/

{

int A=1889,B,C,E;

if((Y%400==0)||((Y%4==0)&&(Y%100!=0))) A=1523;

B=(ord_day+A-122.1)/365.25;

C=ord_da>y+A-floor (365. 25*B) ;

E=C/30.6001;

if(E<13.5) *M=E-1; else *M=E-13;

*D=C-floor(30.6001*E); }

9_06.pas

program ord_to_dat;

uses Crt;

var

Y,M,D,ord_day:integer;

procedure month_day(Y,ord_day:integer;var M,D:integer);

{ Y }

{ ord_day }

{ - }

{ D - } var

,, ,:integer; begin

:=1889;

if(Y mod 400 = 0) OR ((Y mod 4 = 0)AND(Y mod 100 <>0))) then A:=1523;

B:=trunc((ord_day+A-122.1)/365.25) ;

C:=ord_day+A-trunc(365.25 * B);

E:=trunc(C/30.6001);

if(E<13.5) then M:=E-1 else M:=E-13;

D:=C-trunc(30.6001*E); end; begin

clrscr;

write(' : ');

readln(Y);

write (' : ');

readln(ord_day);

month_day(Y,ord_day,M,D);

writeln('Ey = ',, ' = ',D);

readln; end.

9.07.

max_day, .

1 ()

, . 400 4, 100.

9_07.bas

DECLARE FUNCTION MaxDay!(Y%,M%)

REM

DATA 31,28,31,30,31,30,31,31,30,31,30,31

DIM SHARED DAYS(1 TO 12)

FOR J=l TO 12: READ DAYS(J): NEXT J

CLS

INPUT " : ",Y%

INPUT " : ",M%

PRINT " = ";

MaxDay (Y%,M%)

END

FUNCTION MaxDay(Y%,M%)

MaxDay=DAYS(M%)

IF M%<>2 THEN EXIT FUNCTION

IF (Y% MOD 400=0)OR((Y% MOD 4=0)AND(Y% MOD 100<>0) ) THEN MaxDay=29

END IF END FUNCTION

9_07.

#include <stdio.h>

#include <conio.h>

int max_day(int Y, int M);

main() . {

int Y,M;

printf("\n : ");

scanf("%d",&Y);

printf("\3 : ");

scanf("%d",&M);

printf("\n = %d",max_day(Y,M));

getch();

}

/*--------------------------------------*/

int max_day(int Y, int M)

{ int days[]={31,28,31,30,31,31,30,31,30,31,30,31);

if(M != 2) return days[M-l];

if{(Y%400==0)||((Y%4==0)&&(Y%100!=0))}

return 29;

return 28; }

9_07.pas

program days_in_month;

{ }

var

Y,M:integer;

function max_day(Y,M:integer):integer; const

days:array[1..12] of byte=(31,28,31,30,31,30, 31, 31, 30, 31, 30, 31);

begin

max_day:=days[M];

if(M<>2) then exit;

if((Y mod 400=0)OR((Y mod 4=0)AND(Y mod l00<>0) ) ) then

max_day:=29; end; begin

write(' : ');

readln(Y);

write(' : ');

readln(M);

writeln(' = ',max_day(Y,M));

readln; end.

9.08.

calendar, .

1 ()

.

-, , 7 ( ) 6 . 1-

, 1- , 30 31 . 42 .

-, 1- week_day.

, max_day . 42 . .

9_08.bas

DECLARE SUB calendar(Y%,M%)

DECLARE FUNCTION JD!(Y%,M%,DT!)

DECLARE FUNCTION WeekDay!(Y%,M%,D%)

DECLARE FUNCTION MaxDay!(Y%,M%)

REM

DATA 31,28,31,30,31,30,31,31,30,31,30,31

DIM SHARED DAYS(1 TO 12)

FOR j=l TO 12: READ DAYS(j): NEXT j

CLS

INPUT " : ",Y%

INPUT " : ",M4

calendar Y%,M%

END

SUB calendar(Y%,M%)

DIM i AS INTEGER, j AS INTEGER, k AS INTEGER, q AS INTEGER

DIM a(42),b$<7)

b$(0}="": b$(1)=" ": b$(2)="

b$(3)=" ": b$(4)=" ": b$(5)="

b$(6)=""

CLS

PRINT " ";%;" ";Y%;" "

i=WeekDay(Y%,M%,l)

IFi=0 THEN i=7

q-MaxDay(Y%,M%)

FOR j=0 TO 41: a(j)=0: NEXT j

k=l

FOR j=i-l TO q+i-2: a(j)=k: k=k+l: NEXT j

FOR j=0 TO 6

LOCATE j+3,10: PRINT b$(j);

k=0

WHILE k<=35

IF a(k+j)<>0 THEN

PRINT USING "####";a(k+j); ELSE PRINT " ";

END IF k=k+7

WEND NEXT j END SUB

FUNCTION JD(Y%,M%,DT)

DIM a AS INTEGER, b AS INTEGER, mm AS INTEGER, yy AS INTEGER

DIM AS LONG

b=0

yy=Y%

mm=M%

IF M%<3 THEN yy=yy-l: mm=mm+12

a=yy\100

IF Y%+M%/100!+DT/10000>1582.1015# THEN b=b+2-a+a\4

END IF

c=INT(365.25*yy) IF yy<0 THEN c=INT(365.25*yy-.75)

JD=c+INT(30.6001*(mm+1))+DT+1720994.5#+b END FUNCTION

FUNCTION MaxDay(Y%,M%)

MaxDay=DAYS(M%)

IF M%<>2 THEN EXIT FUNCTION

IF (Y% MOD 400=0)OR((Y% MOD 4=0)AND(Y% MOD l00<>0) ) THEN MaxDay=29

END IF END FUNCTION

FUNCTION WeekDay(Y%,M%,D%) dl!=D%+1.5

WeekDay=INT(JD(Y%,M%,dl!)) MOD 7 END FUNCTION

9_08.

#include <stdio.h>

#include <conio.h>

void calendar(int Y,int M);

int week_day(int Y,int M,int D) ;

double JD(int Y,int M,double DT);

int max_day(int Y,int M);

main() {

int Y,M;

clrscr();

printf(" : ");

scanf("%d",&Y);

printf(" : ");

scanf("%d",&M);

calendar(Y,M);

getch(};

}

/*-------------------------------------------*/

void calendar'(int Y, int M) {

int a[42],i, j,k,q;

char *b[7]={"",

" ",

" ",

" ",

" ",

" ",

""}; clrscr();

printf("\t Id %d ",,);

i=week_day(Y,M,1); /* 1.M.Y */

if(i==0)i=7;

q=max day(Y,M); /* */

for(j=0; j<42; j++) a[j]=0;

for(j=i-l,k=l;

j<q+i-l; j++,k++) a[j]=k;

for(j=0; j<7; j++) {

gotoxy{10,j+3);

printf("%s",b[j]);

for(k=0; k<=35; k+=7)

if(a[k+j] != 0) printf("%4d",a[k+j]);

else printf("%4c",' '); }

return;

}

/*----------------------------------------*/

double JD(int Y,int M,double DT)

int a,b=0,m,y;

long c;

y=Y;

m=M;

if (M<3) { y--; m += 12; }

a = y/100;

if(Y+M/100.+DT/10000 > 1582.1015} b += 2-a+(int)(a/4.);

c=365.25*y; if(y<0)c=365.25*y-0.75;

return c+(long)(30.6001*(m+1))+DT+1720994.5+b;

}

/*---------------------------------*/

int week_day(int Y,int M,int D)

{

int q,m;

q = M+10;

m = (M-14)/12 + Y;

return

((13*(q-(q/13)*12)-1)/5+D+77+5*

(m%100)/4+m/400-(m/100)*2)%7;

}

/*-----------------------------------*/

int max_day(int Y,int M)

{ int days[]={31,28,31,30,31,31,30,31,30,31,30,31};

if(M != 2) return days[M-l];

begin

max_day:=days[M];

if (M=2)and((Y mod 400=0) or ( (Y mod 4=0) and (Y mod 100<>0) ) ) then

max_day:=2 9; end;

procedure calendar(Y,M:integer);

var

i,j,k,q:integer; a:array [0..41] of byte;

const

b:array [0..6] of string=('',

' ', ' ',

' ',

' ',

' ', ' '};

begin clrscr;

write(' ',, ' ',Y, ' ');

i:=week_day(Y,M,1);

if 1=0 then i:=7;

q:=max_day(Y,M);

for j:=0 to 41 do

a[j]:=0; k:=l;

for j:=i-l to q+i-2 do begin

a[j]:=k;

inc(k);

end;

for j:=0 to 6 do begin

gotoxy(10, j+3) ;

write(b[j]); k:=0;

while k<= 35 do begin;

if a[k+j] 0 then

write(a[k+j]:4)

else write(' ':4); k:=k+7;

end;

end;

end;

begin {main}

clrscr;

write(' : ');

readln(Y);

write(' : ');

readln(M);

calendar(Y,M);

readln; end.

9.09.

. (H , M -, S ), , t (0<= t <= 1).

9_09.bas

DECLARE SUB UnpackTime(T!,H%,M%,S%)

DECLARE FUNCTION PackTime!(H%,M%,S%)


CLS

%=18: %=0: S%=0

T=PackTime(H%,%,S%)

PRINT USING "##:##:## = ###.##";H%;M%;S%;T

T= 5

UnpackTime T,H%,M%,S%

PRINT USING "##:##:## = ###.##";H%;M%;S%;T

END

FUNCTION PackTime(H%,M%,S%)

' - (%)

' (%) (S%)

PackTime = (% * 3600! + % * 60 + S%) / 86400!

END FUNCTION

SUB UnpackTime(,H%,M%,S%)

' -

' (%), (%) (S%)

t1!=T*86400 H%=INT(tl1/3600! )

t1!=t1!-3600!*H% M%=INT(t1!/60!)

S%=INT(t1!-60!*M%)

END SOB

9_09.c

#include <stdio.h>

#include <conio.h>

double pack_time(int H, int M,int S) ;

void unpack_time(double t,int *H,int *M,int *S);

main() {

int H=18,M=0,S=0;

double T;

clrscr();

T=pack_time(H,M,S);

printf("\n%2d:%2d:%2d=%f",H,M,S,T);

T=0.75;

unpack_time(T,&H, &M,&S);

printf("\n%2d:%2d:%2d=%f",H,M,S,T);

getch();

}

/*----------------------------------------*/

double pack_time(int H,int M,int S)

/****************************************/

/* - () .*/

/* () (S) */

/****************************************/

{

return (H*3600.0+M*60+S)/86400.0; }

/*--------------------------------------*/

void unpack_time(double t,int *H,int *M,int *S)

/* - */

/* (), () (S) */

{

double tl;

t1=t*86400;

*H=t1/3600.0;

t1=t1-3600.0*(*H);

*M=t1/60.0;

*S=t1-60.0*(*M);

}

9_09.pas

program pack_unpack;

uses Crt;

var

H,M,S:integer;

:double;

function pack_time(H,M,S:integer):double;

{ - () () (S) } begin

pack_time:=(H*3600.0+M*60+S)/86400.0;

end;

procedure unpack_time(t:double;var H,M,S:integer);

{ -

(), () (S) }

var

t1:double; begin

t1:=t*86400;

H:=trunc(t1/3600.0) ;

t1:=t1-3600.0*H;

M:=trunc(t1/60.0);

S:=trunc(t1-60.0*M);

end;

begin {main}

clrscr;

H:=18; M:=0; S:=0;

T:=pack_tiine(H,M,S) ;

writeln(H:2,': ',M:2, ': ',S:2, ' =',T:6:2);

T:=0.5;

unpack_time(T,H,M,S);

writeln(H:2, ': ',M:2, ': ',S:2, ' =',T:6:2);

readln;

end.

      . - 3GL   - 4GL   5GL  

, - , , , . , , , . , , , . , , . , , , . , , , .




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution