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
| #include "stdafx.h"
#include "iostream"
#include "conio.h"
#include <math.h>
#include <stdlib.h>
#include "stdio.h"
#include "disk_sp.h"
using namespace std;
FILE *in;
disk_sp mass[1000];
int main()
{
int o=0;
in=fopen("input.txt", "rt");
int m=0;
while (!feof(in))
{
char name[100],type[100],date[100],company[100];
float size,price;
fscanf(in,"%s %f %s %s %s %f",&name,&size,&type,&date,&company,&price);
mass[m]=disk_sp(name,size,type,date,company,price);
m++;
}
fclose(in);
while (1)
{
cout<<"Golovne meniy))"<<endl;
cout<<"1 - Peregliad BD"<<endl<<"2 - Vydalenia odjecta"<<endl;
cout<<"3 - Redaguvaty object"<<endl<<"4 - Dodaty object"<<endl;
cout<<"5 - exit"<<endl;
cin>>o;
switch (o)
{
case 1 : {
for (int i=0;i<m;i++)
{
cout<<endl<<"Disk #"<<i+1<<":"<<endl;
mass[i].show();
}
_getch();
break;
}
case 2: { for (int i=0;i<m;i++)
{
cout<<endl<<"Disk #"<<i+1<<":"<<endl;
mass[i].show();
}
cout<<endl<<"Iakyi object??? ";
int p; cin>>p;
for (int i=p-1;i<m-1;i++)
mass[i]=mass[i+1];
if (p<=m)m--;
break;
}
case 3: {
for (int i=0;i<m;i++)
{
cout<<endl<<"Disk #"<<i+1<<":"<<endl;
mass[i].show();
}
cout<<endl<<"Iakyi object??? ";
int p; cin>>p;
system("cls");
mass[p-1].show(); int q;
cout<<endl<<"Iake pole??"<<endl;
cout<<"1- name, 2- size, 3- type, 4- date, 5- company, 6- price"<<endl;
cin>>q;
cout<<"Vvidit novi dani - "<<endl;
switch (q)
{
case 1: { char name[20]; cin>>name; mass[p-1].set_name(name); break; }
case 2: { float size; cin>>size; mass[p-1].set_size(size); break; }
case 3: {char type[5]; cin>>type; mass[p-1].set_type(type); break; }
case 4: {char date[11]; cin>>date; mass[p-1].set_date(date); break; }
case 5: {char company[20]; cin>>company; mass[p-1].set_company(company); break; }
case 6: {float price; cin>>price; mass[p-1].set_price(price); break; }
}
system("cls");
mass[p-1].show();
_getch();
break;
}
case 4: {
char name[20],type[6],date[13],company[20];
float size,price;
cout<<"Vvidit novi dani - "<<endl;
cout<<"Name - "; cin>>name;
cout<<"Size(Gb) - "; cin>>size;
cout<<"Type - "; cin>>type;
cout<<"Date of creation - "; cin>>date;
cout<<"Company - "; cin>>company;
cout<<"Price - "; cin>>price;
mass[m]=disk_sp(name,size,type,date,company,price);
m++;
break;
}
case 5 : {
cout<<"zberegty???? (1 - tak, 2 - ni)"<<endl;
int y;
cin>>y;
if (y=1){ in=fopen("input.txt","wt");
for (int i=0;i<m-1; i++)
fprintf(in,"%s %f %s %s %s %f\n",mass[i].name,mass[i].size,mass[i].type,
mass[i].date,mass[i].company,mass[i].price);
fprintf(in,"%s %f %s %s %s %f",mass[m-1].name,mass[m-1].size,mass[m-1].type,
mass[m-1].date,mass[m-1].company,mass[m-1].price);
fclose(in);
}
return 0;
}
default : break;
}
system("cls");
}
} |