67862
1
1

'

()

: " "

:

" "

1 -131

..

: ..

______________________

ʳ : __________

: ECTS _____

񳿠 ________________ ..

()

________________ ..

()

. 2014

.

.

ϳ : . , .

:

1. .

2. .

3. 1 ( ).

4. 2 ( ).

5. 3 ( ).

6. 4 ( ).

7. 5 ( ).

8. ( ).

9. ( ).

10. .

, . ( -) .

, "".

" " , . .

" 0" - "5" 䳿 . .

" " " " . , . . .

"" . ().

, , .

.

. ᒺ - 㳺.

.

(A, B, C, D).

, :

- ( ),

- ( ),

- ,

- .

13.

. ᒺ . ᒺ:

Ø ϲ;

Ø ;

Ø (, , ..);

Ø ;

Ø ;

Ø .

:

1. .

2. , .

3. () .

4. ϳ , .

5. , , .


" ": "". .

. "", .

, . , .

. .

, .

, , , . .

.

2 : 1.


1.jpg

̲

6

1 7

2 8

2.1. 18

2.1.1. 8

2.1.2. 8
2.1.3. 9
2.1.4. 10
2.1.5. 10
2.1. 211

2.2.1. 11

2.jpg 2.2.2. 11
2.2.3. 12
2.2.4. 13
2.2.5. 13
2.1. 314

2.3.1. 14

 2.3.2. 14
2.3.3. 15
2.3.4. 16
2.3.5. 17
2.1. 418

2.4.1. 18

 2.4.2. 18
2.4.3. 19
2.4.4. 20
2.4.5. 20
2.1. 521

2.5.1. 21

5.jpg 2.5.2. 21
2.5.3. 22
2.5.4. 23
2.5.5. 23
3. 25

3.1. 25

3.2. 25

 4. 25
5. 26
5.1. 26
5.2. 26

5.3. 26
5.4. 27

5.5. ϒ 27

5.6. 27

  5.7. 28
5.8. 29

5.9. 29
6. 30

31
31
˳ 32


. , , , , . ,  .

, , , , . , , 񳺿 . , , , .

- " ". ³ , , . , , 䳿 . , , , , .

, , , .


1.

³ , , ' . ᒺ:

Ø ϲ;

Ø ;

Ø (, , ..);

Ø ;

Ø ;

Ø ;

sell, :

1. ϲ FIO, F, , IO, - .

2. adds, str, , , h, , .

3. ³ dep, , .

4. post, , .

5. exp, , .

6. wage, , , , .


2.

' :

ü .

ü , .

ü () .

ü ϳ , .

ü , , .

2.1. 1

²

ֲ ²IJ

2.1.1.

1) .

2) ³ .

3) .

4) .

5) , 1).

6) , 7)

7) ³ .

8) , 1).

9) .

2.1.2.

:

Ø .bin, ;

Ø sell, sell_max, ;

Ø i , - sort_dep.

2.1.3.

1. .

2. ³ A.bin (r).

3. A.bin , 4, 5.

4. 1 (return 1).

5. Seller with max experience from every department .

6. A.bin, 7, 17.

7. A.bin.

8. A.bin, 9, 17.

9. sell_max sell.

10. A.bin, 11, 17.

11. A.bin.

12. A.bin, 13, 17.

13. sell_max.dep sell.dep, 14, 16.

14. sell_max.exp , sell.exp, 15, 10.

15. sell_max sell.
10.

16. sell_max.FIO.F, sell_max.FIO.IO, sell_max.adds.str, sell_max.dep, sell_max.post, sell_max.adds.h, sell_max.exp, sell_max.wage.
10.

17. sell_max.FIO.F, sell_max.FIO.IO, sell_max.adds.str, sell_max.dep, sell_max.post, sell_max.adds.h, sell_max.exp, sell_max.wage.
.

18. A.bin 0 (return 0).


2.1.4.

int function_1 () , , .

printf (" 1:\n");

result=function_1 ();

if (result==1)

printf(" 1 \n");

:

int function_1 ()

{

printf (" 1 \n");

int result;

scanf ("%d", &result)

return result;

}

2.1.5

11.

:

1: 1-2-3

2: 1-2-4-5-6-7-8-9-10-11-12-24-25-26-27-28

3: 1-2-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27-28

1

: .bin.

: .

2

: .bin.

: .

3

: .bin.

: .


2.2. 2

² ֲ, ²IJ

2.2.1.

1) .

2) ³ .

3) .

4) .

5) , 1).

6) ³ .

7) .

8) , 1).

9) - .

10) .

11) ³ .

12) .

13) , 10).

14) , 1).

15) .

2.2.2.

Ø .bin, ;

Ø sell, ;

Ø i , - sort_dep.


2.2.3.

1. .

2. ³ A.bin (r).

3. A.bin , 4, 5.

4. 1 (return 1).

5. Sellers addresses by departments.

6. A.bin, 7, 16.

7. A.bin.

8. A.bin, 9, 16.

9. sell.adds.str, sell.adds.h, sell.dep.

10. A.bin, 11, 14.

11. A.bin.

12. A.bin, 13, 10.

13. sell.adds.str, sell.adds.h, sell.dep.
10.

14. .

15. A.bin.

16. 0 (return 0).


2.2.4.

int function_1 () , , .

printf (" 2:\n");

result=function_2 ();

if (result==1)

printf(" 2 \n");

:

int function_2 ()

{

printf (" 2 \n");

int result;

scanf ("%d", &result)

return result;

}

2.2.5

9.

:

1: 1-2-3

2: 1-2-4-24

3: 1-2-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24

1

: .bin.

: .

2

: .bin.

: .

3

: .bin.

: , .


2.3. 3

² (ֲ)

2.3.1.

1) .

2) ³ .

3) .

4) .

5) , 1).

6) , 7)

7) ³ .

8) , 1).

9) .

2.3.2.

Ø .bin, ;

Ø T.bin, () ;

Ø sell, ;

Ø wage_min, .


2.3.3.

1. ³ A.bin (r).

2. A.bin , 3, 4.

3. 1 (return 1).

4. A.bin, 5, 12.

5. A.bin.

6. A.bin, 7, 12.

7. wage_min sell.wage. T.bin , (w+).

8. .bin , 9, 10.

9. 1 (return 1).

10. .bin.

11. .bin.

12. A.bin, 13, 27.

13. A.bin.

14. A.bin, 15, 12.

15. sell.wage wage_min, 16, 21.

16. ³ .bin , (a+).

17. .bin , 18, 19

18. 1 (return 1).

19. .bin.

20. .bin.

21. sell.wage , wage_min, 22, 12.

22. wage_min sell.wage. T.bin , (w+).

23. .bin , 24, 25.

24. 1 (return 1).

25. .bin.

26. T.bin. 12.

27. ³ T.bin , (r+).

28. .bin , 29, 30.

29. 1 (return 1).

30. Seller with minimal sallary.

31. .bin.

32. .bin .bin.

33. 0 (return 0).

2.3.4.

int function_1 () , , .

printf (" 3:\n");

result=function_3 ();

if (result==1)

printf(" 3 \n");

:

int function_3 ()

{

printf (" 3 \n");

int result;

scanf ("%d", &result)

return result;

}


2.3.5

12.

:

1: 1-2

2: 1-2-4-5-6-7-8-9

3: 1-2-4-5-6-7-8-10-11-12-13-14-15-16-17

4: 1-2-4-5-6-7-8-10-11-12-13-14-15-16-18-19-20-21-22

5: 1-2-24-25-26-27

6: 1-2-4-5-6-7-8-10-11-12-13-14-15-16-18-19-20-21-23-24 -25-26-27

1

: .bin.

: .

2

: .bin.

: .

3

: .bin.

: .

4

: .bin.

: .

5

: .bin.

: .

6

: .bin.

: () .


2.4. 4

ϲ ʲʲҲ ֲ,

ʲ ²IJ˲

2.4.1.

1) .

2) ³ .

3) .

4) .

5) , 1).

6) ³ .

7) .

8) , 1).

9) .

10) .

11) ³ .

12) .

13) , 10).

14) , 1).

15) .

2.4.2.

Ø , ;

Ø sell, ;

Ø sell_dep, , ;

Ø i , - sort_dep.

Ø k_dep, , .


2.4.3.

1. .

2. ³ A.bin (r).

3. A.bin , 4, 5.

4. 1 (return 1).

5. A.bin, 6, 18.

6. A.bin.

7. A.bin, 8, 15.

8. Sellers quantity in departments .

9. k_dep 1. sell.dep sell_dep.

10. A.bin, 11, 17.

11. A.bin.

12. A.bin, 13, 10.

13. sell_dep sell.dep, 14, 15.

14. k_dep k_dep+1. 10.

15. sell_dep k_dep.

16. k_dep 1. sell.dep sell_dep. 10.

17. sell_dep, k_dep
.

18. .bin. 0 (return 0).


2.4.4.

int function_1 () , , .

printf (" 4:\n");

result=function_4 ();

if (result==1)

printf(" 4 \n");

:

int function_4 ()

{

printf (" 4 \n");

int result;

scanf ("%d", &result)

return result;

}

2.4.5

10.

:

1: 1-2-3

2: 1-2-27

3: 1-2-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27

1

: .bin.

: .

2

: .bin.

: .

3

: .bin.

: , .


2.5. 5

, ,

2.5.1.

1) .

2) ³ .

3) .

4) , 1).

5) .

6) , 1).

7) .

2.5.2.

Ø A.bin, ;

Ø sell, ; sell_post, , , ;

Ø sell_adds_str, , ;

Ø sell_adds_hc, , ;

Ø sell_adds_h, , ;

Ø flag, 0, , 1, , ;

Ø i , - .


2.5.3.

1. ³ A.bin (r).

2. A.bin , 3, 4.

3. 1 (return 1).

4. flag 0.

5. A.bin.

6. A.bin .

7. Input sellers address.

8. sell_adds_h sell_adds_hc.

9. 2 sell_adds_hc.

10. sell_adds_hc ,
11, 13.

11. Wrong data was insert.

12. A.bin. 1 (return 1).

13. A.bin, 14, 21.

14. A.bin.

15. A.bin, 16, 13.

16. sell.adds.h sell_adds_h sell.adds.str sell_adds_str 1, 17, 13.

17. flag 0, 18, 20.

18. flag 1.

19. , sell.post, sell.adds.str sell.adds.h. 13.

20. sell.post, sell.adds.str, sell.adds.h.
13.

21. flag 0, 22, 23.

22. No address in data.

23. .

24. A.bin . 0 (return 0).


2.5.4.

int function_5 () , , .

printf (" 5:\n");

result=function_5 ();

if (result==1)

printf(" 5 \n");

:

int function_5 ()

{

printf (" 5 \n");

int result;

scanf ("%d", &result)

return result;

}

2.5.5

11.

:

1: 1-2

2: 1-2-4-5

3: 1-2-4-5-6

4: 1-2-4-5-22-23-28

5: 1-2-4-5-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-24-25-26-27-28

1

: .bin.

: .

2

: .bin.

: .

3

: sell_adds_h ().

: Wrong data was insert..

4

: , .bin.

: No address in data.

5

: .bin, sell_adds_h, .bin.

: , , .


3.

ϳ , . :

1) ;

2) .

3.1.

, , - , <Enter> <Space>, - .

.

, , .

3.2.

, , admin , admin .

, .

.

4.

, . , , , . , .


5.

, , . Course Work Programming1.sln. .

( ), .

, ( ), .

ϳ , (Welcome to admin mode! ; Welcome to user mode! - ), No data, , .

9 :

5.1.

<1> . . - , <0> <7> . , - , <0> <7> <Esc>. , <Esc>.

5.2.

<2> . , . - , <0> <7> . , - , <0> <7> <Esc>. , <Esc>.

5.3.

<3> . () . - , <0> <7> . , - , <0> <7> <Esc>. , <Esc>.


5.4.

<4> . , . - , <0> <7> . , - , <0> <7> <Esc>. , <Esc>.

5.5. ϒ

<5> . , , . . , No address ( ) ( ) in data.. ( ), Wrong data was inserted.. - , <0> <7> . , - , <0> <7> <Esc>. , <Esc>.

5.6.

<6> . . . ϳ , <Space> <Enter> , :

1) ;

2) - ( );

3) , ;

4) , ( );

5) , ;

6) , ;

7) , ;

8) ,  .

100 , , 100 .

100 , check_data , .


4) 7) 8) ( ), Wrong data was inserted. .

- , <0> <7> . , - , <0> <7> <Esc>. , <Esc>.

5.7.

<7> . . . ϳ , , <Space> <Enter> , :

1) ;

2) - ( );

3) , ;

4) , ( );

5) , ;

6) , ;

7) , ;

8) ,  .

100 , , 100 .

100 , check_data , .

4) 7) 8) ( ), Wrong data was inserted. .

- , <0> <7> . , - , <0> <7> <Esc>. , <Esc>.


5.8.

<0> . , . - , <0> <7> . , - , <0> <7> <Esc>. , <Esc>.

5.9.

< Esc > . . <Esc> .

6.

ϳ ,

, ,

, .

, .

.

1

2 -

3 -

4 -

5 -

.


" ". , . , , , . . , 100% . , .

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


1. . .: - , 1991. 128 .

2. . Borland C++ /. . .: , 1999. 800 .

3. ., . : . . . .: -, 2002. 1168 .

4. .., .. . : , 2005. 136 .

5. .. ᒺ- . . . . : , 2006. 182 .

6. . /++ (4- ).

7. 7.080403 - /.: .. , .. ,

.. , .. . - : , 2010 - 47 .

8. " 6.050103." ..


˳

global variable.h

struct adds_type {char str[13]; int h;};

struct fio_type {char F[15], IO[3];};

struct sell_type {fio_type FIO; adds_type adds; char dep[16], post[11]; int exp; float wage;};

sell_type sell;

check.h

int char_to_int (char str[], int* a) /* ,

*/

{

int num,i,flag;

i=0;

flag=1;

while (str[i]!='\0')

if (str[i]>='0' && str[i]<='9')

i++;

else

{

flag=0;

i++;

}

if (flag==0)

return 1;

i=0;

num=0;

while (str[i]!='\0')

{

num=num*10+str[i]-48;

i++;

}

*a=num;

return 0;

}

int char_to_float (char str[], float* a) /* ,

*/

{

int i, n_point, flag;

float num;

i=0;

flag=1;

n_point=0;

*a=0;

num=1;

while (str[i]!='\0')

if (str[i]>='0' && str[i]<='9')

i++;

else

if (str[i]=='.')

{

i++;

n_point++;

}

else

{

flag=0;

i++;

}


if ((flag==0) || (n_point>1))

return 1;

i=0;

while ((str[i]!='\0') && (str[i]!='.'))

{

*a=*a*10+str[i]-48;

i++;

}

while (str[i]!='\0')

{

if (str[i]!='.')

{

num/=10;

*a+=(str[i]-48)*num;

}

i++;

}

return 0;

}

int check_data() /* */

{

char f[100], io[100], str [100], h[100], dep[100], post[100], exp[100], wage[100];

int i_h, i_exp;

float f_wage;

scanf ("%s", f);

scanf ("%s", io);

scanf ("%s", str);

scanf ("%s", h);

scanf ("%s", dep);

scanf ("%s", post);

scanf ("%s", exp);

scanf ("%s", wage);

printf ("\n");

f[14]='\0';

io[2]='\0';

str[12]='\0';

h[2]='\0';

dep[15]='\0';

post[10]='\0';

exp[5]='\0';

wage[10]='\0';

if (char_to_int (h, &i_h))

return 1;

if (char_to_int (exp, &i_exp))

return 1;

if (char_to_float (wage, &f_wage)||(f_wage>=10000000))

return 1;

strcpy (sell.FIO.F, f);

strcpy (sell.FIO.IO, io);

strcpy (sell.adds.str, str);

sell.adds.h=i_h;

strcpy (sell.dep, dep);

strcpy (sell.post, post);

sell.exp=i_exp;

sell.wage=f_wage;

return 0;

}


data.h

void read_string (FILE *A) /* */

{

fread (&sell.FIO.F, sizeof(char), 13 ,A);

fread (&sell.FIO.IO, sizeof(char), 2, A);

fread (&sell.adds.str, sizeof(char), 12, A);

fread (&sell.adds.h, sizeof(int), 1, A);

fread (&sell.dep, sizeof(char), 15, A);

fread (&sell.post, sizeof(char), 10, A);

fread (&sell.exp, sizeof(int), 1, A);

fread (&sell.wage, sizeof(float), 1, A);

}

void write_string (FILE *A) /* */

{

fwrite (&sell.FIO.F, sizeof(char), 13 ,A);

fwrite (&sell.FIO.IO, sizeof(char), 2, A);

fwrite (&sell.adds.str, sizeof(char), 12, A);

fwrite (&sell.adds.h, sizeof(int), 1, A);

fwrite (&sell.dep, sizeof(char), 15, A);

fwrite (&sell.post, sizeof(char), 10, A);

fwrite (&sell.exp, sizeof(int), 1, A);

fwrite (&sell.wage, sizeof(float), 1, A);

}

void print_data (FILE *A) /* */

{

int i;

for (i=0;i<79;i++)

printf("-");

printf ("\n| Familia IO | Address | Department | Post | Exp | Wage |\n");

for (i=0;i<79;i++)

printf("-");

printf("\n");

while(!feof(A))

{

read_string (A);

if(!feof(A))

printf("|%14s %2s|%12s %2d|%15s|%10s|%5d|%10.2f|\n",

sell.FIO.F, sell.FIO.IO, sell.adds.str, sell.adds.h, sell.dep,

sell.post, sell.exp, sell.wage);

}

for (i=0;i<79;i++)

printf("-");

printf("\n");

}


int function_6 () /* */

{

FILE *A;

A=fopen ("A.bin"," a+");

if (A==NULL)

return 1;

print_data(A);

rewind(A);

printf ("Add new seller to base\n");

if (check_data())

{

printf ("Wrong data was insert.\n");

fclose(A);

return 1;

}

write_string (A);

fclose(A);

return 0;

}

int function_7 () /* */

{

FILE *A,*T;

sell_type sell_del;

A=fopen("A.bin"," r+");

if (A==NULL)

return 1;

print_data(A);

rewind(A);

printf ("Delete seller from base\n");

if (check_data())

{

printf ("Wrong data was insert.\n");

fclose(A);

return 1;

}

sell_del=sell;

while (!feof (A))

{

read_string (A);

if (!feof (A))

if (strcmp (sell.FIO.F, sell_del.FIO.F) ||

strcmp (sell.FIO.IO, sell_del.FIO.IO) ||

strcmp (sell.adds.str, sell_del.adds.str) ||

(sell.adds.h!=sell_del.adds.h) ||

strcmp (sell.dep, sell_del.dep) ||

strcmp (sell.post, sell_del.post) ||

(sell.exp!=sell_del.exp) || (sell.wage!=sell_del.wage))

{

T=fopen ("T.bin"," a+");

if (T==NULL)

return 1;

write_string (T);

fclose (T);

}

}

fclose (A);

remove ("A.bin");

rename ("T.bin", "A.bin");

return 0;

}


departmaent sorting.h

int sort_dep () /* */

{

FILE *A,*B,*C,*T;

char sort_dep[16];

A=fopen ("A.bin","r+");

if (A==NULL)

return 1;

B=fopen ("B.bin","w+");

if (B==NULL)

return 1;

while (!feof(A))

{

read_string (A);

if(!feof(A))

write_string (B);

}

fclose (A);

fclose (B);

B=fopen ("B.bin","r+");

if (B==NULL)

return 1;

T=fopen ("T.bin","w+");

if (T==NULL)

return 1;

while (!feof(B))

{

read_string (B);

if (!feof (B))

{

C=fopen ("C.bin","w+");

if (C==NULL)

return 1;

strcpy(sort_dep, sell.dep);

write_string (T);

while (!feof (B))

{

read_string (B);

if (!feof (B))

{

if (!strcmp(sell.dep, sort_dep))

write_string (T);

else write_string (C);

}

}

fclose (C);

fclose (B);

remove ("B.bin");

rename ("C.bin", "B.bin");

B=fopen ("B.bin","r+");

if (B==NULL)

return 1;

}

}

fclose (T);

fclose (B);

remove ("A.bin");

remove ("B.bin");

rename ("T.bin", "A.bin");

return 0;

}


functions.h

int function_1 () /*

*/

{

FILE *A;

sell_type sell_max;

int i;

i=sort_dep ();

A=fopen ("A.bin","r");

if (A==NULL)

return 1;

printf ("Seller with max experience from every department:\n");

for (i=0;i<79;i++)

printf("-");

printf ("\n| Familia IO | Address | Department | Post | Exp | Wage |\n");

for (i=0;i<79;i++)

printf("-");

printf("\n");

if (!feof(A))

{

read_string (A);

if (!feof(A))

{

sell_max=sell;

while (!feof(A))

{

read_string (A);

if (!feof(A))

if(!strcmp (sell_max.dep,sell.dep))

{

if (sell_max.exp<sell.exp)

sell_max=sell;

}

else

{

printf ("|%14s %2s|%12s %2d|%15s|%10s|%5d|%10.2f|\n",

sell_max.FIO.F, sell_max.FIO.IO, sell_max.adds.str,

sell_max.adds.h, sell_max.dep, sell_max.post, sell_max.exp, sell_max.wage);

sell_max=sell;

}

}

}

}

printf ("|%14s %2s|%12s %2d|%15s|%10s|%5d|%10.2f|\n",sell_max.FIO.F, sell_max.FIO.IO,

sell_max.adds.str, sell_max.adds.h, sell_max.dep, sell_max.post, sell_max.exp,

sell_max.wage);

for (i=0;i<79;i++)

printf("-");

printf ("\n");

fclose (A);

return 0;

}


int function_2 () /* , */

{

int i;

FILE *A;

i=sort_dep ();

A=fopen ("A.bin","r");

if (A==NULL)

return 1;

printf ("Sellers' addresses by departments:\n");

if (!feof (A))

{

read_string (A);

if (!feof (A))

{

for (i=0;i<33;i++)

printf ("-");

printf ("\n| Address | Department |\n");

for (i=0;i<33;i++)

printf ("-");

printf ("\n");

printf ("|%12s %2d|%15s|\n", sell.adds.str, sell.adds.h, sell.dep);

while (!feof (A))

{

read_string (A);

if (!feof (A))

printf ("|%12s %2d|%15s|\n", sell.adds.str, sell.adds.h,

sell.dep);

}

for (i=0;i<33;i++)

printf ("-");

printf ("\n");

fclose (A);

}

}

return 0;

}


int function_3 () /* () */

{

FILE *A,*T;

float wage_min;

A=fopen ("A.bin","r");

if (A==NULL)

return 1;

if (!feof (A))

{

read_string (A);

if (!feof(A))

{

wage_min=sell.wage;

T=fopen ("T.bin"," w+");

if (T==NULL)

return 1;

write_string (T);

fclose (T);

}

}

while (!feof (A))

{

read_string (A);

if (!feof(A))

{

if (sell.wage==wage_min)

{

T=fopen ("T.bin","a+");

if (T==NULL)

return 1;

write_string (T);

fclose(T);

}

if (sell.wage<wage_min)

{

wage_min=sell.wage;

T=fopen ("T.bin"," w+");

if (T==NULL)

return 1;

write_string (T);

fclose (T);

}

}

}

fclose (A);

T=fopen("T.bin"," r+");

if (T==NULL)

return 1;

printf ("Seller with minimal sallary:\n");

print_data (T);

fclose (T);

remove ("T.bin");

return 0;

}


int function_4 () /* , */

{

FILE *A;

char sell_dep[16];

int i,k_dep;

i=sort_dep();

A=fopen("A.bin","r");

if (A==NULL)

return 1;

if (!feof(A))

{

read_string (A);

if (!feof (A))

{

printf ("Sellers' quantaty in departments:\n");

for (i=0;i<22;i++)

printf("-");

printf ("\n| Department |Q-ty|\n");

for (i=0;i<22;i++)

printf("-");

printf("\n");

k_dep=1;

strcpy (sell_dep, sell.dep);

while (!feof (A))

{

read_string (A);

if(!feof(A))

if(!strcmp(sell_dep,sell.dep))

k_dep++;

else

{

printf ("|%15s|%4d|\n", sell_dep, k_dep);

k_dep=1;

strcpy(sell_dep,sell.dep);

}

}

}

printf ("|%15s|%4d|\n", sell_dep, k_dep);

for (i=0;i<22;i++)

printf ("-");

printf ("\n");

}

fclose (A);

return 0;

}


int function_5 () /* , ,

*/

{

FILE *A;

char sell_post[10], sell_adds_str[100], sell_adds_hc[100];

int i, flag=0, sell_adds_h;

A=fopen ("A.bin","r");

if (A==NULL)

return 1;

print_data (A);

rewind (A);

printf ("Input seller's address: ");

scanf ("%12s%2s",sell_adds_str,sell_adds_hc);

sell_adds_hc[2]='\0';

if (char_to_int(sell_adds_hc,&sell_adds_h))

{

printf ("Wrong data was insert.\n");

fclose(A);

return 1;

}

while(!feof(A))

{

read_string (A);

if(!feof(A))

if (!(strcmp (sell_adds_str, sell.adds.str)) && (sell_adds_h==sell.adds.h))

if (flag==0)

{

flag=1;

for (i=0;i<28;i++)

printf ("-");

printf ("\n| Post | Address |\n");

for (i=0;i<28;i++)

printf("-");

printf("\n");

printf ("|%10s|%12s %2d|\n", sell.post, sell.adds.str,

sell.adds.h);

}

else printf ("|%10s|%12s %2d|\n",sell.post,sell.adds.str,sell.adds.h);

}

if (flag==0)

printf ("No address %12s %2d in data.\n", sell_adds_str, sell_adds_h);

else

{

for (i=0;i<28;i++)

printf("-");

printf("\n");

}

fclose (A);

return 0;

}


int function_0 () /* */

{

int i;

for (i=0;i<79;i++)

printf("-");

printf("\n");

printf ("\t \t \t \t Welcome!\n");

printf ("\t \t You are using the course work programm\n");

printf ("\t \t Made by the student of group AC-131\n");

printf ("\t \t Romanjuk Konstantin Georgievich\n");

printf ("\t \t \t \t Variant 13\n");

for (i=0;i<79;i++)

printf("-");

printf("\n\n");

printf ("Predmetnaya oblast - supermarket. Objekt - prodavez.\n\n");

printf ("Dannie ob objekte - FIO, Address, Otdel, Dolzhnost, Stag raboti, Zarplata.\n\n");

printf ("In this course work programm I realized 7 functions.\n\n");

printf ("Function 0: Show the author and the course work task.\n");

printf ("Function 1: Show one seller with maximal experience from every department.\n");

printf ("Function 2: Show sellers' adresses, grouped in departments.\n");

printf ("Function 3: Find seller with minimal salary.\n");

printf ("Function 4: Sellers' quantaty in departments.\n");

printf ("Function 5: Find seller's post by his address.\n");

printf ("Function 6: Insert seller.\n");

printf ("Function 7: Delete seller.\n\n");

return 0;

}


#include <stdio.h>

#include <conio.h>

#include <string.h>

#include <windows.h>

#include "global variable.h"

#include "check.h"

#include "data.h"

#include "department sorting.h"

#include "functions.h"

int main() /*, , , , */

{

char user[15], pass[15], ch;

int n_admin;

int i;

FILE *A;

printf ("User: "); scanf ("%s",user);

printf ("Pass: "); scanf ("%s",pass);

if (!(strcmp(user,"admin") || strcmp(pass,"admin")))

{

printf("Welcome to admin mode!\n");

n_admin=1;

}

else

{

printf("Welcome to user mode!\n");

n_admin=0;

}

do

{

A=fopen("A.bin","r+");

if (A!=NULL)

{

print_data(A);

fclose(A);

}

else printf ("No data");

printf ("\n 1. Show one seller with maximal experience from every department.\n");

printf ("2. Show sellers' adresses, grouped in departments.\n");

printf ("3. Find seller with minimal salary.\n");

printf ("4. Sellers' quantaty in departments.\n");

printf ("5. Find seller's post by his address.\n");

printf ("6. Insert seller (only admin mode).\n");

printf ("7. Delete seller (only admin mode).\n");

printf ("8. Show the author and the course work task.\n");

printf ("Exit - ESC\n");

ch = getch();

system ("cls");

switch (ch)

{

case 49: i=function_1(); break; case 50: i=function_2(); break;

case 51: i=function_3(); break; case 52: i=function_4(); break;

case 53: i=function_5(); break;

case 54:

if(n_admin==1)

i=function_6();

else printf ("This function works only in admin mode.\n");

break;

case 55:

if (n_admin==1)

i=function_7();

else printf ("This function works only in admin mode.\n");

break;

case 27: printf ("Thank you for good work. Good bye.\n"); break;

default: break;

case 56: i=function_8(); break;

}

}

while (ch!=27);

getch();

return 0;

}


« »
: ,
: 67862
: 1
: 1

40651
4
0

... ) i i, i i. 1.4 . , . ...

143644
51
28

... , - , . 2. - . , ...

19171
1
4

... . , . .3. ' . , ...

259712
25
12

... ( ) . . 5.4 , - , , , , , ...

0