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
| #include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <string.h>
#define MAXTIT 40
#define MAXCOLS 20
#define STOP "-"
main()
{
struct row {char value[64];};
struct integer {char title[MAXTIT];int value[50];} nt[MAXCOLS];
struct real {char title[MAXTIT];double value[50];} ft[MAXCOLS];
struct stringn {char title[MAXTIT];struct row str[50];} chn[MAXCOLS];
struct string {char title[MAXTIT];struct row str[50];} ch[MAXCOLS];
char tmp1[60];int i=0,nti=0,n,l;
cout<<"Љ®«"<<"ђп¤"<<"‡**з"<<endl<<endl;
ifstream f; f.open("kurs.txt");
while (!f.eof())
{
f.get(tmp1[0]);
switch (tmp1[0]){
case 'i':f.getline(nt[i].title,sizeof(nt[i].title));
cout<<nt[i].title<<endl;
f.getline(tmp1,sizeof(tmp1));
while (strcmp(tmp1,STOP))
{
nt[i].value[nti]=atoi(tmp1);
cout<<i<<" "<<nti<<" "<<nt[i].value[nti]<<endl;
nti++; f.getline(tmp1,sizeof(tmp1));
}
nti=0; i++; break;
case 'f':f.getline(ft[i].title,sizeof(ft[i].title));
cout<<ft[i].title<<endl;
f.getline(tmp1,sizeof(tmp1));
while (strcmp(tmp1,STOP))
{
ft[i].value[nti]=atof(tmp1);
cout<<i<<' '<<nti<<' '<<ft[i].value[nti]<<endl;
nti++; f.getline(tmp1,sizeof(tmp1));
}
nti=0; i++; break;
case 'c':f.getline(ch[i].title,sizeof(ch[i].title));
cout<<ch[i].title<<endl;
f.getline(ch[i].str[nti].value,sizeof(ch[i].str[nti].value));
while (strcmp(ch[i].str[nti].value,STOP))
{
cout<<i<<' '<<nti<<' '<<ch[i].str[nti].value<<endl; nti++;
f.getline(ch[i].str[nti].value,sizeof(ch[i].str[nti].value));
}
nti=0;i++;break;
case 'n':f.getline(chn[i].title,sizeof(chn[i].title));
cout<<chn[i].title<<endl;
f.getline(tmp1,sizeof(tmp1));
n=atoi(tmp1);
f.getline(tmp1,sizeof(tmp1));
while (strcmp(tmp1,STOP))
{
for (l=0;l<n;l++) chn[i].str[nti].value[l]=tmp1[l];
chn[i].str[nti].value[l]=NULL;
l=0;
cout<<i<<' '<<nti<<' '<<chn[i].str[nti].value<<endl;
f.getline(tmp1,sizeof(tmp1));nti++;
}
nti=0;i++;break;
}
}
f.close();
cin.get();
} |