0 / 0 / 0
Регистрация: 13.01.2019
Сообщений: 20
|
|
1
|
Программа должна хранить данные в массиве перед записью в файл и после чтения данных из файла
14.01.2019, 04:16. Показов 451. Ответов 0
Программа должна хранить данные в массиве перед записью в файл и после чтения данных из файла.
Правильно ли я это записал или нет?
Выделил жырным шрифтом!
C++ | 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
| #include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <windows.h>
#include <fstream>
#include "conio.h"
#include <math.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
menu:
int a, b, i, r;
int numer;
do
{
cout << "Baza danych ksiazek" << endl << endl;
cout << " Ksiazki: " << endl << endl;
cout << "1.ksiazki z biblioteki :" << endl;
cout << "2.Ksiazki z pliku:" << endl;
cout << "3.Dodaj ksiazku do pliku:" << endl;
cout << "4.Wyjdz z biblioteki" <<endl;
switch(char ch=_getch())
{
case '4': exit(1);
}
cout <<"Wybor"<< endl;
cin >> b;
switch(b)
{
case 1:{
cout << "Wybierz zanr" << endl << endl;
cout << " Zanr: " << endl << endl;
cout << "11.Historia:" << endl;
cout << "12.Powiesc:" << endl;
cout << "13.Przygoda:" << endl <<endl;
break;
}
default : { cout << "Zly wybor,wybierz wartosc od 1 do 4" << endl;
goto menu;
break;
}
[B]case 2:{
const int len = 20, strings = 20;
const char ch = '\n';
char mas[len][strings];
ifstream fs("23c.txt", ios::in | ios::binary);
if(!fs) return 1;
for(r = 0; r<strings; r++)
{
fs.getline(mas[r],ch);
cout << mas[r] << endl;
}
ifstream plik("23c.txt");
cout << plik.rdbuf();
cout << endl;
goto menu;
fs.close();
break;
}[/B]
case 3: {
string Ksianzki = "23c.txt";
ofstream plik;
plik.open("23c.txt",ofstream::app);
if (plik.good()==false)
{
cout << "Plik pust!!!!";
}
else
{
for (i =0; i<5; i++)
switch(i)
{
case 0:{ cout <<"Tytul :"<<endl;
string Tytul;
cin >> Tytul;
plik <<"Tytul: " << Tytul <<endl;
break;
}
case 1:{ cout <<"Autor :" <<endl;
string Autor;
cin >> Autor;
plik <<"Autor: " << Autor <<endl;
break;
}
case 2:{ cout <<"Wydawnictwo :" <<endl;
string Wydawnictwo;
cin >> Wydawnictwo;
plik <<"Wydawnictwo: " << Wydawnictwo <<endl;
break;
}
case 3:{ cout <<"Numer :" <<endl;
string Numer;
cin >> Numer;
plik <<"Numer: " << Numer <<endl<<endl;
cout <<"KSIANZKU DODANO DO PLIKU!!! "<<endl<<endl;
goto menu;
break;
}
}
}
}
case 4:{ cout << "Aby potwierdzic, nacisnij 4 jeszcze raz! " << endl <<endl;
break;
}
}
{
cout << "Pisac tutaj: ";
cin >> a;
cout << endl;
}
switch(a)
{
case 11:{
cout << " Historyczne ksiazki"<<endl;
cout << endl;
cout << "16.Przeminelo z wiatrem" << endl;
cout << "17.Katedra Notre-Dame" << endl;
break;
}
case 12:{
cout << " Romantyczne ksiazki";
cout << endl;
cout << "21.Mieszanie losуw" << endl;
cout << "22.Kryminalny rycerz" << endl;
break;
}
case 13:{
cout << " Przygodowe ksiazki";
cout << endl;
cout << "31.Trzej muszkieterowie" << endl;
cout << "32.Zelazny krуl" << endl;
break;
}
}
cout << "Wybor: ";
if (numer == 1, 2, 3, 4)
cin >> numer;
switch (numer)
{
case 4:{ cout << "Dowidzenia" << endl;
break;
}
default : { cout << "Zly wybor,wybierz wartosc od 1 do 3" << endl;
break;
}
case 16:{ cout << "\t Tytul: Przeminelo z wiatrem" << endl;
cout << "\t Autor:Margaret Mitchell;" << endl;
cout << "\t Wydawnictwo: PocketBook;" << endl;
cout <<"\t Numer: 20112018" << endl;
cout << endl;
break;
}
case 17:{ cout <<"\t Tytul: Katedra Notre-Dame" << endl;
cout << "\t Autor: Victor Marie Hugo ;" << endl;
cout << "\t Wydawnictwo: PocketBook ;" << endl;
cout << "\t Numer: 20122018" << endl;
cout << endl;
break;
}
case 21:{ cout << "\t Tytul: Mieszanie losуw" << endl;
cout << "\t Autor: Woodward Franciszka;" << endl;
cout << "\t Wydawnictwo: Fikcja;" << endl;
cout << "\t Numer: 20212018" << endl;
cout << endl;
break;
}
case 22:{ cout << "\t Tytul: Kryminalny rycerz" << endl;
cout << "\t Autor: Victoria Selezneva;" << endl;
cout << "\t Wydawnictwo: Abc-Atticus;" << endl;
cout << "\t Numer: 20222018" << endl;
cout << endl;
break;
}
case 31:{ cout << "\t Tytul: Trzej muszkieterowie" << endl;
cout << "\t Autor: Dumas Aleksander;" << endl;
cout << "\t Wydawnictwo: BC;" << endl;
cout << "\t Numer: 20312018" << endl;
cout << endl;
break;
}
case 32:{ cout << "\t Tytul: Zelazny krуl" << endl;
cout << "\t Autor: Driuos Maurice;" << endl;
cout << "\t Wydawnictwo: Eksmo;" << endl;
cout << "\t Numer: 20322018" << endl;
cout << endl;
break;
}
}
}
while(numer != 4);
return 0;
} |
|
0
|