Вы находитесь на странице: 1из 19

.

220201


:
: -

21

:
..

: 607081
: 2 (.)

2008

..3
1. . ...5
1.1. ..5
1.2. .5
1.3. .5
1.4. .6
2. ..7
2.1. ...7
2.2. - .12
2.3. 16
4. ...18
5. ...19
5.1. 19

.
:

,
,
;

.
:
I. - , :
.
:
1.

() .

2.

... .

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

:
1....
2.
3. ( )
4.
5.
6. .
7. ( )
3

II. , 20 .

III- . ,
, , ..
.
III. :
) 30 60
) , .
) , 20 . . 50
..
) 55
.
IV. -.
V. ,
( ),
,
, .

.

1. .
1.1 .
-

++.
++
. ( )
(Borland C++ Builder 6.),
Borland .
1.2. .
, , 2-
Sotrs.dat ( ) Proj.dat ( ). Sotrs.dat
, . Proj.dat
, .
1.3 .
tab1 tab2,
. ,
, (. .).

1- (struct tab1).

nomer
fam
im
och
pol
gor
ulic
dk
tel
staj
dat

-
4 bytes
null-terminated string1
null-terminated string
null-terminated string
null-terminated string
null-terminated string
null-terminated string
null-terminated string
null-terminated string
null-terminated string
4 bytes

.1
C++
int
char*
char*
char*
char*
char*
char*
char*
char*
char*
int

Null-terminated string ( ) .
; .

mes
god
obraz
ucheb

obteh
proek
okl
deti

4 bytes
4 bytes
null-terminated string
null-terminated string

int
int
char*
char*

null-terminated string
4 bytes
4 bytes
4 bytes

char*
int
int
int

2- (struct tab2).

fam
im
och
raz
tip
ndat
nmes
ngod
kdat
kmes
kgod
eff
tef

-
null-terminated string
null-terminated string
null-terminated string
null-terminated string
null-terminated string

.2
C++
char*
char*
char*
char*
char*

4 bytes
4 bytes
4 bytes

int
int
int

4 bytes
4 bytes
4 bytes
4 bytes
null-terminated string

int
int
int
long int
unsigned char

1.4. .
: MS-Windows 9-x, Me, NT, 2k, 2k3, XP, Vista;
: 8 Mb ;
CPU: Intel 386 ;
: 4 Mb ;
10 .
++ .

2. .
6

2.1. .
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
struct tab1
{
int nomer;
char fam[15];
char im[15]; char och[15];
char pol[5]; char gor[20];
char ulic[20]; char dk[10];
char tel[10]; int staj;
int den; int mes; int god;
char obraz[30];
char ucheb[15]; char obteh[30];
int proek;
int okl;
int deti;
};
struct tab2
{
char fam[15]; char im[15];
char och[15]; char raz[70];
char tip[15];
int nden; int nmes; int ngod;
int kden; int kmes; int kgod;
int eff; char tef[20];
};
tab1 a[100]; // a[0], b[0] !!
tab2 b[100];
int s,k; // ,
FILE *Inp, *Inp2;
//----------------------------------------------------------------------------//
void savetab()
{ FILE *Inp1, *Inp2;
Inp1=fopen ("sotrs.dat", "w");
//
for (int i=0;i<s ;i++)
{ fwrite(&a[i],sizeof(tab1),1, Inp1);
}
fclose(Inp1);
Inp2=fopen ("projs.dat", "w");
//
for (int i=0;i<k ;i++)
{ fwrite(&b[i],sizeof(tab2),1, Inp2);
}
fclose(Inp2);
}
//----------------------------------------------------------------------------//
void readtab()
{ FILE *Inp1, *Inp2;
Inp1=fopen ("sotrs.dat", "r"); //
int i=0;
while (!feof(Inp1))
{fread(&a[i], sizeof(tab1),1, Inp1);
i++;
}
s=i-1;
fclose(Inp1);
Inp2=fopen ("projs.dat", "r");

//

int j=0;
while (!feof(Inp2))
{fread(&b[j], sizeof(tab2),1, Inp2);
j++;
}
k=j-1;
fclose(Inp2);
}
//----------------------------------------------------------------------------//
void printlist ()
{
int i;
for (i=0; i<s; i++)
{
textcolor (6);
cprintf("%d ", a[i].nomer);
printf ("%s ", a[i].fam);
printf ("%s ", a[i].im);
printf ("%s ", a[i].och); textcolor (9);
gotoxy (50, i+1); cprintf ("Kol-vo proektov : %d\n\r", a[i].proek);
}
}
//----------------------------------------------------------------------------// j- (j+1)-
void swapa(int &j)
{ tab1 tmp;
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
//----------------------------------------------------------------------------// - 30 60
void sortVozr3060()
{
int i, j=0;
textcolor (10);
cprintf ("Sotrudniki v vozraste ot 30 do 60 let:\n\r");
textcolor (6);
for (i=0; i<s; i++)
if ( (2008-a[i].god>30)
&& (2008-a[i].god<60) )
{
textcolor (6);
cprintf ("%d ", a[i].nomer);
printf ("%s ", a[i].fam);
printf ("%s ", a[i].im);
printf ("%s", a[i].och);
textcolor (9);
gotoxy (40, j+2);
cprintf ("god %d ", a[i].god);
cprintf ("vozr %d\n\r", 2008-a[i].god);
j++;
}
}
//----------------------------------------------------------------------------// - ,
void sortFamMtoA()
{
int i,j;
textcolor (10);
cprintf ("Sortirovka po familii ( ot M do A ):\n\n\r");

textcolor (6);
// (A- X)
for (i=0; i<s; i++)
for (j=0; j<(s-1); j++)
if (strcmp(a[j].fam, a[j+1].fam)>0)
swapa(j);
// , (.. N)
for (i=s-1;i>=0;i--)
if (strcmp(a[i].fam,"N")<0)
{cprintf ("%d ", a[i].nomer);
printf ("%s ", a[i].fam);
printf ("%s ", a[i].im);
printf ("%s\n\r", a[i].och);
}
}
//----------------------------------------------------------------------------// - 55
void sortTel55()
{
int i,j=3;
clrscr ();
textcolor (10);
cprintf ("Sotrudniki s nomerom telefona 55****** : \n\n\r");
for (i=0; i<s; i++)
if ( (a[i].tel[0]=='5')
&& (a[i].tel[1]=='5') )
{
textcolor (6);
cprintf ("%d ", a[i].nomer);
printf ("%s ", a[i].fam);
printf ("%s ", a[i].im);
printf ("%s", a[i].och);
textcolor (9);
gotoxy (50, j++); cprintf ("%s\n\r", a[i].tel);
}
}
//----------------------------------------------------------------------------// - ,
// 20000 50000
void sortEff20to50()
{ cprintf ("Sotrudniki imeyushie effect ot razrabotok > 20000p <50000p :\n\n\r");
int i,j ;
long int tmpEff;
//
for (i=0; i<s; i++)
{ tmpEff=0;
for (j=0; j<k; j++)
//
{ if(strcmp(a[i].fam, b[j].fam)==0 &&
strcmp(a[i].im, b[j].im)==0 &&
strcmp(a[i].och, b[j].och)==0 ) //
{tmpEff=tmpEff+b[j].eff;}
}
if ((tmpEff>20000)&&(tmpEff<50000))
{
printf ("%s ", a[i].fam); //
printf ("%s ", a[i].im);
printf ("%s", a[i].och);
textcolor (9);
cprintf (" Summarniy Effect = %ld p.\n\r", tmpEff);
}
}
}

//----------------------------------------------------------------------------//
int dobsotr()
{
textcolor (10);
cprintf ("Dobavleniennie Sotridnika :\n\n\r");
//s -
printf ("Tabelniy nomer sotrudnika (Primer: 1) : ");
scanf ("%d", &a[s].nomer);
printf ("Familia : ");
scanf ("%s", &a[s].fam);
printf ("Name : ");
scanf ("%s", &a[s].im);
printf ("Ochestvo : ");
scanf ("%s", &a[s].och);
printf ("Pol sotrudnika (m/g): ");
scanf ("%s", &a[s].pol);
printf ("Gorod v kotorom progivaet sotrudnik (Primer: Cheboksari) : ");
scanf ("%s", &a[s].gor);
printf ("Ulica na kotoroy progivaet sotrudnik (Primer: Afanas'eva) : ");
scanf ("%s", &a[s].ulic);
printf ("Nomer doma/Kvartira (Primer: 16/23) : ");
scanf ("%s", &a[s].dk);
printf ("Domashniy telefon (Primer: 87-98-01) : ");
scanf ("%s", &a[s].tel);
printf ("Staj Raboti (Primer: 5) : ");
scanf ("%d", &a[s].staj);
printf ("Data rojdeniya (Primer: 20 10 1980) : ");
scanf ("%d", &a[s].den);
scanf ("%d", &a[s].mes);
scanf ("%d", &a[s].god);
printf ("Obrazovanie (Primer: Visshee-teh) : ");
scanf ("%s", &a[s].obraz);
printf ("Kakoe uchebnoe zavedenie okonchil (Primer: MGOU) : ");
scanf ("%s", &a[s].ucheb);
printf ("Oblast' tehniki : ");
scanf ("%s", &a[s].obteh);
printf ("Kolichestvo proektov : ");
scanf ("%d", &a[s].proek);
printf ("Oklad : ");
scanf ("%d", &a[s].okl);
printf ("Kolichestvo detey : ");
scanf ("%d", &a[s].deti);
//
FILE *Inp1;
Inp1=fopen ("sotrs.dat", "a");
fwrite(&a[s],sizeof(tab1),1, Inp1);
fclose(Inp1);
if (a[s].proek>0) // ,
{
textcolor (10);
cprintf ("\n\n\Opisanie Proekta ili razrabotki :\r");
for (int i=0; i<a[s].proek; i++)
{ strncpy(b[k].fam,a[s].fam, sizeof(b[k].fam)-1);
strncpy(b[k].im,a[s].im, sizeof(b[k].im)-1);
strncpy(b[k].och,a[s].och, sizeof(b[k].och)-1);
printf ("\n\nNaimenovanie %d-ogo proekta ili razrabotki:\n(Vvoditsa_bes_probelov): ",i+1);
scanf ("%s", &b[k].raz);
printf ("Tip (Proekt ili Razrabotka) : ");
scanf ("%s", &b[k].tip);

10

printf ("Data nachala sozdaniya proekta (Primer: 20 11 1999) : ");


scanf ("%d", &b[k].nden);
scanf ("%d", &b[k].nmes);
scanf ("%d", &b[k].ngod);
printf ("Data konca sozdaniya proekta (Primer: 01 10 2000) : ");
scanf ("%d", &b[k].kden);
scanf ("%d", &b[k].kmes);
scanf ("%d", &b[k].kgod);
printf ("Polucheniy effekt v rub. : ");
scanf ("%d", &b[k].eff);
printf ("Tip effecta (Tehnicheskiy ili Ekonomicheskiy) : ");
scanf ("%s", &b[k].tef);
//
FILE *Inp2;
Inp2=fopen ("projs.dat", "a");
fwrite(&b[k],sizeof(tab2),1, Inp2);
fclose(Inp2);
k=k+1;
}
}
s=s+1;
return 0;
}
//---------------------------------------------------------------------------//
int main()
{
char let;
clrscr();
readtab(); //
do
{
clrscr ();
cprintf ("Kursovoj project Cvetkovoj N.V. \n\r");
cprintf (" \n\r");
textcolor (10);
cprintf ("Vibirite deystvie :\n\n\r");
textcolor (11);
cprintf ("[1] - Zapros #1 (Sotrudniki v vozraste ot 30 do 60 let)\n\r");
cprintf ("[2] - Zapros #2 (Sortirovka po familii ( ot M do A ))\n\r");
cprintf ("[3] - Zapros #3 (Sotrudniki imeyushie effect ot razrabotok > 20000p <50000p)\n\r");
cprintf ("[4] - Zapros #4 (Sotrudniki s nomerom telefona 55******)\n\r");
cprintf ("[5] - Dobavit' sotrudnika\n\r");
cprintf ("[6] - Spisok sotrudnikov\n\r");
cprintf ("[0] - End program");
let=getch();
switch (let)
{
case '1' : clrscr() ; sortVozr3060() ; getch(); break;
case '2' : clrscr() ; sortFamMtoA(); getch(); break;
case '3' : clrscr() ; sortEff20to50(); getch(); break;
case '4' : clrscr() ; sortTel55();
getch(); break;
case '5' : clrscr() ; dobsotr(); savetab(); getch(); break;
case '6' : clrscr() ; printlist();
getch(); break;
case '0' : return 1;
default : clrscr (); break;
}
}
while (1); //
}
/ /-------------------------------------------------------------------------------------------------------------------------

11

2.2. .
2.2.1. 30 60 .

START

i, j

i=0S-1

+
-

2008-a.god >30
2008-a.god <60

+
a

END

12

2.2.2. ,

START

i, j

i=0S-1

+
-

j=0S-1

+


>0

j=0S-1

+
.fam<M

+
a

END
13

j=0S-1
2.2.3. ,

20 . . 50 ..

.fam<M

+
a

END

14

START

i, j, tmpEff

i=0S-1

tmpEff=0

j=0K-1

+
,
,
,b

+
tmpEff = tmpEff + b.Eff

tmpEff > 20000


< 50000

+
a, tmpEff

END
2.2.4.
55 .
15

START

i, j

i=0S-1

+
-

a. tel= 5
a. tel= 5

+
a

END

2.3. .
2.3.1. .
16

2.3..2. .

2.3..3. 1- .

2.3.4. 2- .

17

2.3.5. 3- .

2.3.6. 4- .

18

.., .. . ++. 4-
. - . - :
, 2002
: : / .
.. , .. , .. . .: ..-. 2005 -100 .

19

Оценить