Каранин Алексей 08-ПМ Вариант include stdio include stdlib include str

 1
 2
 3
 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
Каранин Алексей 08-ПМ
Вариант 7
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 10
typedef struct
{
char fio[20];
char gr[10];
char birthday[13];
}student;
void main()
{
FILE *fin, *fout,*fout1;
int i,j;
student students[10];
student tmp;
char c;
fin=fopen("kurs.in","r");
if (fin==NULL)
{printf("Can't open file kurs.in\n"); exit(1);}
fout=fopen("kurs1.out","w");
if (fout==NULL)
{printf("Can't open file kurs1.out\n"); exit(1);}
fout1=fopen("kurs2.out","w");
if (fout1==NULL)
{printf("Can't open file kurs2.out\n"); exit(1);}
fscanf(fin,"%c", &c);
for (i=0;i<N;i++)
{
fscanf(fin,"%s", &students[i].fio);
fscanf(fin,"%s", &students[i].gr);
fscanf(fin,"%s", &students[i].birthday);
for (j=0; j<strlen(students[i].fio);j++)
{students[i].fio[j]-=2;
if ((students[i].fio[j]==(char)191)||
(students[i].fio[j]==(char)190)||
(students[i].fio[j]==(char)222)||
(students[i].fio[j]==(char)223))
students[i].fio[j]+=32;
}
}
for (i=0;i<N;i++)
for (j=i+1;j<N;j++)
if ((int)students[i].fio[0]>(int)students[j].fio[0])
{
tmp=students[i];
students[i]=students[j];students[j]=tmp;
}
for (i=0;i<N;i++)
{
fprintf(fout,"%s %s %s \n",students[i].fio,students[i].gr,students[i].birthday);
}
fprintf(fout1,"Все фамилии на букву %c: \n",c);
for (i=0;i<N;i++){
for (j=0; j<strlen(students[i].fio);j++)
{if ((students[i].fio[j]==(char)254)||
(students[i].fio[j]==(char)255)||
(students[i].fio[j]==(char)222)||
(students[i].fio[j]==(char)223))
students[i].fio[j]-=32;
students[i].fio[j]+=2;
}
if (students[i].fio[0]==c)
fprintf(fout1,"%s %s %s \n",students[i].fio,students[i].gr,students[i].birthday);
}
}