Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int fmax(int a, int b, int c) {
- int max = 0;
- if (a > max)
- max = a;
- if (b > max)
- max = b;
- if (c > max)
- max = c;
- return max;
- }
- int main() {
- int r, g, b;
- cin >> r >> g >> b;
- int a = fmax(r, g, b);
- double k = 1 - (a / 255.);
- if (abs(k - 1) < 0.0000000001)
- cout << "0 " << "0 " << "1 " << "0";
- else {
- double c = (1 - r / 255. - k) / (1 - k);
- double m = (1 - g / 255. - k) / (1 - k);
- double y = (1 - b / 255. - k) / (1 - k);
- cout.precision(4);
- cout << c << " " << m << " " << y << " " << k;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement