If i enter the fallowing:
0 0 0 23 2 20 3
I expect
0, 0, 0
11, 1, 10
23, 2, 20
but i recive
0, 0, 0
12, 1, 10
23, 2, 20
double r1, g1, b1, r2, g2, b2, n, r, g, b;
cin >> r1 >> g1 >> b1 >> r2 >> g2 >> b2 >> n;
r = r2 - r1;
g = g2 - g1;
b = b2 - b1;
cout << r1 << ", " << g1 << ", " << b1 << endl;
//...
n -= 2;
//cout<<trunc(r / (1 + 1));
for (double i = 1; i <= n; i++)
{
cout << abs(trunc(r / (i + 1))) << endl;
r -= abs(trunc(r / (i + 1)));
cout << r << endl;
b -= abs(trunc(b / (i + 1)));
g -= abs(trunc(g / (g + 1)));
cout << r << ", " << g << ", " << b << endl;
}
cout << r2 << ", " << g2 << ", " << b2;
Aucun commentaire:
Enregistrer un commentaire