Вот код программы:
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
| #include <iostream>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <Windows.h>
using namespace std;
int n;
int t;
int T;
int s;
int p;
int sum;
int d;
int i;
int j;
class times
{
public:
void hour()
{
time_t rawtime;
//struct tm * timeinfo;
time( &rawtime );
//timeinfo = localtime( &rawtime );
s = localtime( &rawtime ) -> tm_hour;
d = localtime( &rawtime )-> tm_min;
}
};
class temp
{
public:
void temperature()
{
srand (unsigned (time(0)));
t = 23 + rand() % 6;
cout << "t = " << t << endl;
}
};
class internalsensor
{
public:
void internal()
{
cout << "\ninternal sensor \n" << endl;
cout << "T = " << T << endl;
}
};
class externalsensor
{
public:
void external()
{
cout << "\nexternal sensor \n" << endl;
temp mytemp;
mytemp.temperature();
}
};
class consumable
{
public:
void energy()
{
p = 1000;
sum = s*p;
}
};
class radiator
{
public:
void heat()
{
cout << "\nradiator "<< endl;
if ( t >= 22 & T >= 22 )
cout << "turn off" << endl;
else
cout << "turn on" << endl;
}
};
class conditioner
{
public:
void cold1()
{
cout << "\nconditioner \n" << "p = " << p << " Vt" << endl;
if ( t >= 26 & 0 <= s <= 8 & sum <= 5000)
cout << "turn on" << endl;
else
cout << "turn off" << endl;
}
};
class fan
{
public:
void cold2()
{
cout << "\nfan "<< endl;
if ( t >= 23 & 9 <= s <= 19 || sum > 5000)
cout << "turn on\n" << endl;
else
cout << "turn off\n" << endl;
}
};
int main()
{
for (i = 0; i <= 25 - s; i++)
{
times mytimes;
mytimes.hour();
s = s + i;
if (s >= 23)
i = i - 24;
cout << "time = " << s << " hour " << d << " min\n" << endl;
consumable myconsumable;
myconsumable.energy();
internalsensor myinternalsensor;
for (n = 0; n >= 0; n++);
{
T = 20 + n/2 + sqrt(n);
if (n >= 3)
n = n - 3;
}
myinternalsensor.internal();
externalsensor myexternalsensor;
myexternalsensor.external();
radiator myradiator;
myradiator.heat();
conditioner myconditioner;
myconditioner.cold1();
fan myfan;
myfan.cold2();
srand (unsigned (time(0)));
Sleep(5000);
}
return 0;
} |
|
В классе internalsensor внутри функции main(), цикл выдает далеко не те значения, которые должны выдаваться по формуле, зачем он выдает время работы в мили-секундах не знаю. Прошу вас решить эту проблему.