. , , ,

,,,

-

.

. 2004


1.                蠠 _________________________________ 3

2.                蠠 _________________________________ 5

3.                堠 _________________________________ 8

4.                _______________________________ 11

5.                _________________________________ 12


. .

, , (. . 1).

 

. 1

r, :

(1.1)

: r ;

k .

k . k=0 .

, N . . ( - ) :

(1.2)

:

, (.. ). , . , .

24- . .


1.               

. .

. , . . :

                    ;

                    .

r. :

, .

, .

(1.1).

- [0 - 1].

, , , . , [0 - 1]. [0 - 1] n , , , n. ; . (1.1) :

;

;

.

(.) .

, , , , ,

, ( (1.2)).

, , , , , :

. . 3.

 


. 3

, . . , :

(1.3)

- ( ).

:

(1.4)

:

(1.5)

[0 - 1] , (1.5) :

(1.6)

(1.6) , , .


2.               

C Borland C++ 3.1.

-

 

 

 


Kas1.c :

float RND_DIG (void) - [0, 1];

void massive (void) - ;

float _tau(void) - ;

float time_to(void) - . 蠠 lambda;

void inf (void) - .


1.                :

A:\Kas1.exe

2.                :

\\ :

() .

3.                :

:

lambda

4. :

tau_min .

4.                :

tau_max .

5.                :

( .):

hours - .

6.                :

:

MO - .

7.                :

:

SKO - .

8. , .


5.

/* */

#include<stdio.h> // -

#include<conio.h> //

#include<math.h> //

#include<alloc.h> // .

//

float RND_DIG( void ); // - .

void inf( void); // - -

void massive( void ); // -

float _tau( void ); // -

float time_to ( void ); //

//

float

tau_min, // . -

tau_max, // . -

*tau, // . -

current_time, // .

minutes, // .

lambda, // - -

enter_time_, //

MO, // . - -

SKO, // . - -

t_free, // .

t_free_av, // .

serve_av, // . % -

refuse_av, // . % -

N0=7836, // 1- .

NI=4792, // 2- .

N, // N0 NI

ND; // 4 N

int

m, // -

i, // .

enter, // -

hours, //

serve, // - -

refuse, // - -

stand, // -

INDPAS; //

//

void main(void)

{

inf(); // c

textcolor( 14 ); //

textbackground( 1 );

clrscr(); //

/* */

printf("\n████████████████████████████████████████████████████████████████████████████████");

for(i=1;i<=21;i++)

printf("█ █");

printf("████████████████████████████████████████████████████████████████████████████████");

gotoxy(10,7);

do

{

printf("\n█\t "

" \\ :");

scanf( "%d", &m );

}

while( (m<=0)||(m>=100) );

do

{

printf( "\n█\t "

" " );

printf( "\n█\t\t :" );

scanf( "%f", &lambda );

}while( lambda<=0 );

clrscr();

//

printf("\n████████████████████████████████████████████████████████████████████████████████");

for(i=1;i<=21;i++)

printf("█ █");

printf("████████████████████████████████████████████████████████████████████████████████");

gotoxy(5,3);

do

{

printf( "\n█\n█\t " );

printf( "\n█\t\t\t :" );

scanf( "%f", &tau_min );

}while( tau_min<=0 );

do

{

printf( "\n█\t " );

printf( "\n█\t\t\t :" );

scanf( "%f", &tau_max );

}while( tau_max<=tau_min );

do

{

printf( "\n█\t ( .):" );

scanf( "%d", &hours );

}while( hours<=0 );

do

{

printf("\n█\t ");

printf( "\n█\t\t :");

scanf( "%f", &MO );

}while( MO<=0 );

do

{

printf( "\n█\t ");

printf( "\n█\t :");

scanf( "%f", &SKO );

}while( SKO<=0 );

massive(); //

minutes=floor( hours*60 ); //

enter=0; //

serve=0; //

refuse=0; //

t_free=0; //

current_time=0; //

enter_time_=time_to(); //

/*

for( current_time=0; current_time<=minutes; current_time++ )

{

/* - - */

if( current_time )

for( i=1; i<=m ;i++)

if( tau[i] ) // , -

tau[i]--; // 1 .

else // ,

t_free++; // .

if( enter_time_<=current_time )

{

enter++; // ,

enter_time_=time_to(); // , ?

i=1; // 1-

INDPAS=1; //

do

{

if( tau[i]<=0 ) // ,

{ //- ,

tau[i]=_tau();

INDPAS=0; //,

}

i++; //

}while((i<=m) && (INDPAS==1));

if( INDPAS==1 ) // ,

refuse++;

if( INDPAS==0) // ,

serve++;

}

}

stand=0; //

i=1; //

do

{

if( tau[i]>0 ) // - ,

stand++; // -

i++; //

}while( i<=m );

serve-=stand; // -

t_free_av=(float)t_free/m; // .

serve_av=(float)serve/enter; // . %

refuse_av=(float)refuse/enter; // . %

textcolor(1); //

textbackground(2);

clrscr();

_setcursortype( _NOCURSOR );

/*

//

printf("\n████████████████████████████████████████████████████████████████████████████████");

for(i=1;i<=21;i++)

printf("█ █");

printf("████████████████████████████████████████████████████████████████████████████████");

gotoxy(3,3);

printf( "\n█\n█\t╔════════════════════════════════════════════════════════════╗ ");

printf(" \n█\t║ %d : %d .",m,hours );

gotoxy(70,6);

printf("║");

printf(" \n█\t║ %d .", enter );

gotoxy(70,7);

printf("║");

printf(" \n█\t║");

gotoxy(70,8);

printf("║");

printf(" \n█\t║\n█\t║  %d ().", serve);

gotoxy(70,9);

printf("║");

printf(" \n█\n█\t║ 蠠 %d ().", refuse);

gotoxy(70,10);

printf("║");

printf(" \n█\n█\t║ %d (). ", stand);

gotoxy(70,11);

printf("║");

printf(" \n█\n█\t║ ⠠ %.2f%%", serve_av*100);

gotoxy(70,12);

printf("║");

printf(" \n█\n█\t║ 蠠 %.2f%%", refuse_av*100);

gotoxy(70,13);

printf("║");

printf(" \n█\n█\t║ : %.0f. %.0f . ",floor( t_free/60 ),

t_free-floor( t_free/60 )*60 );

gotoxy(70,14);

printf("║");

printf(" \n█\n█\t║ 1 : %.0f. %.0f .",

floor( t_free_av/60 ), t_free_av-floor( t_free_av/60 )*60);

gotoxy(70,15);

printf("║");

gotoxy(70,16);

printf("║");

printf(" \n█\t╚════════════════════════════════════════════════════════════╝ ");

getch();

}

// 0 1

float RND_DIG (void)

{

float

x; // 0 1

N=(NI*N0);

ND=floor(N/100);

ND=(ND/10000-floor(ND/10000))*10000; // 2

N0=NI;

NI=ND;

x=ND/9999;

return x;

}

//- -

void massive( void )

{

int i;

tau=(float *)malloc( (m+1)*sizeof(float) );

/* */

for(i=1; i<=m; i++)

tau[i]=0;

}

// - . -

float _tau( void )

{

float

x, // x

y, // y

z, // z

tau_; //

//

//---------------------

if( floor ( ( float )i/2 )==ceil( ( float )i/2 ) )

{

x=RND_DIG(); // .

y=RND_DIG(); // .

if( x>=.0001) // , z

z=sqrt( -2*log( x ) )*sin( 2*M_PI*y );

else

{

if( sin( 2*M_PI*y )<=0 )

z=0; // , z=0

else

z=(float)minutes/2; // 2- - ,

} //- z .

tau_=MO+z*SKO; // -

if( tau_<0 ) // , 1 .

tau_=1;

}

else

{

x=RND_DIG(); // .

/* - */

//--------------------------------------------------

tau_=floor( tau_min+x*( tau_max-tau_min )+.5);

}

return floor( tau_+.5 ); //

}

// - - .

// - lambda

// ============================================================

float time_to( void )

{

int

j; // - -

float

x, // . -

tau, //

a, // - -

n, //

S; // - -

n=floor( minutes/2+0.5 );

x=RND_DIG(); // .

tau=0;

j=0;

a=exp( (lambda * (-1)) ); // . - -

S=0;

do

{

if( S>=x && x<S+a ) // - [S ; S+a)

break;

tau++;

j++;

S+=a;

a*=lambda/j;

}

while( tau<=n );

return current_time+tau; // -

}

. . 2004

 

 

 

! , , , .
. , :