-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpronto.cpp
More file actions
44 lines (38 loc) · 823 Bytes
/
pronto.cpp
File metadata and controls
44 lines (38 loc) · 823 Bytes
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
/*
input pronto code stream
output duration of mark/space in micro-second
$ g++ -o pronto pronto.cpp
$ cat hex | ./pronto
*/
#include <iostream>
using namespace std;
short s;
float k;
void output(int i) {
static bool mark = true;
s = (short)(k * i);
if (mark) cout << s << " ";
else cout << s << endl;
mark = !mark;
}
int main() {
int m, last = 0;
while (!cin.eof()) {
cin >> hex >> m;
if (!cin) break;
if (m) {
// cout << (int)(k * last) << endl;
output(last);
last = m;
} else {
if (last) output(0);
if (cin.eof()) break; cin >> hex >> last;
k = 0.214246;
k *= last;
if (cin.eof()) break; cin >> hex >> last;
if (cin.eof()) break; cin >> hex >> last;
if (cin.eof()) break; cin >> hex >> last;
}
}
output(0);
}