blob: 37ca68b59b93e5ba029facdb999e5b71da2f040d (
plain) (
blame)
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
|
#include <iostream>
struct Packet {
int time;
int temperature;
int pressure;
int humidity;
int elevation;
};
void sortByTime(Packet* data, int N) {
for (int i = 0; i < N-1; i++) {
for (int j = 0; j < N-1 - i; j++) {
if (data[j].time > data[j+1].time) {
Packet temp = data[j];
data[j] = data[j+1];
data[j+1] = temp;
}
}
}
}
int getValue(const Packet& packet, char specifier) {
switch (specifier) {
case 't': return packet.temperature;
case 'p': return packet.pressure;
case 'h': return packet.humidity;
case 'e': return packet.elevation;
}
return 0;
}
int main() {
int N;
std::cin >> N;
Packet* data = new Packet[N];
for (int i = 0; i < N; i++) {
std::cin >> data[i].time
>> data[i].temperature
>> data[i].pressure
>> data[i].humidity
>> data[i].elevation;
}
char wantedValue;
std::cin >> wantedValue;
sortByTime(data, N);
std::cout << getValue(data[0], wantedValue);
for (int i = 1; i < N; i++) {
std::cout << " " << (getValue(data[i], wantedValue) - getValue(data[0], wantedValue));
}
std::cout << std::endl;
delete[] data;
}
|