-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-convert.cc
More file actions
39 lines (30 loc) · 762 Bytes
/
script-convert.cc
File metadata and controls
39 lines (30 loc) · 762 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
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
// asymmetric
int main(int argc, char *argv[])
{
if (argc != 5)
{
cout << "Usage: " << argv[0] << " <og_start> <og_end> <new_start> <new_end>" << endl;
return 1;
}
int og_start = atoi(argv[1]);
int og_end = atoi(argv[2]);
int new_start = atoi(argv[3]);
int new_end = atoi(argv[4]);
if (new_end == new_start)
{
cout << "Error: Division by zero." << endl;
return 1;
}
int scaled_value = (og_start - og_end) / (new_start - new_end);
int zero_point = (scaled_value * new_start) - og_start;
int x;
while (cin >> x)
{
x = round(scaled_value * x + zero_point);
}
return x;
}