# A代码填充--学画画

A代码填充--学画画

#include <iostream>
using namespace std;
class RGB
{
public:
RGB(int r=0,int g=0,int b=0);
friend RGB operator+(RGB &,RGB &);
friend RGB operator*(int ,RGB &);
friend RGB operator/(RGB &,int);
friend ostream& operator<<(ostream&,RGB&);
friend istream& operator>>(istream&,RGB&);
RGB RGBmix(RGB &rgb1,RGB &rgb2,int m,int n);
private:
int red,green,blue;
};
RGB::RGB(int r,int g,int b)
{
red=r;
green=g;
blue =b;
}
istream& operator>>(istream &in,RGB &rgb)
{
in>>rgb.red>>rgb.green>>rgb.blue;
return in;
}
ostream& operator<<(ostream &out,RGB &rgb)
{
out<<rgb.red<<","<<rgb.green<<","<<rgb.blue<<endl;
return out;
}
RGB operator*(int n,RGB &rgb)
{
return RGB(n*rgb.red,n*rgb.green,n*rgb.blue);
}
/*
请在该部分补充缺少的代码
*/

RGB RGB::RGBmix(RGB &rgb1,RGB &rgb2,int m,int n)
{
RGB t,t1,t2;
t=(t1=m*rgb1)+(t2=n*rgb2);
return t/(m+n);
}

int main()
{
RGB rgb1,rgb2,rgb;
int m,n;
cin>>rgb1>>rgb2;
cin>>m>>n;
rgb =rgb.RGBmix(rgb1,rgb2,m,n);
cout<<rgb<<endl;
return 0;
}

``````0 0 0 255 255 255
1 1``````

``127,127,127``

``````#include<stdio.h>
int main()
{
int r1,g1,b1,m,n,r2,g2,b2;
int s1=0,s2=0,s3=0;
scanf("%d%d%d%d%d%d",&r1,&g1,&b1,&r2,&g2,&b2);
scanf("%d%d",&m,&n);
s1=(m*r1+n*r2)/(m+n);
s2=(m*g1+n*g2)/(m+n);
s3=(m*b1+n*b2)/(m+n);
printf("%d,%d,%d\n",s1,s2,s3);
return 0;
}
``````

``````
#include <iostream>
using namespace std;
class RGB
{
public:
RGB(int r=0,int g=0,int b=0);
friend RGB operator+(RGB &,RGB &);
friend RGB operator*(int ,RGB &);
friend RGB operator/(RGB &,int);
friend ostream& operator<<(ostream&,RGB&);
friend istream& operator>>(istream&,RGB&);
RGB RGBmix(RGB &rgb1,RGB &rgb2,int m,int n);
private:
int red,green,blue;
};
RGB::RGB(int r,int g,int b)
{
red=r;
green=g;
blue =b;
}
istream& operator>>(istream &in,RGB &rgb)
{
in>>rgb.red>>rgb.green>>rgb.blue;
return in;
}
ostream& operator<<(ostream &out,RGB &rgb)
{
out<<rgb.red<<","<<rgb.green<<","<<rgb.blue<<endl;
return out;
}
RGB operator*(int n,RGB &rgb)
{
return RGB(n*rgb.red,n*rgb.green,n*rgb.blue);
}
RGB operator/(RGB &rgb,int n)
{
return RGB(rgb.red/n,rgb.green/n,rgb.blue/n);
}
RGB operator+(RGB &rgb1,RGB &rgb2)
{
return RGB(rgb1.red+rgb2.red,rgb1.green+rgb2.green,rgb1.blue+rgb2.blue);
}
RGB RGB::RGBmix(RGB &rgb1,RGB &rgb2,int m,int n)
{
RGB t,t1,t2;
t=(t1=m*rgb1)+(t2=n*rgb2);
return t/(m+n);
}

int main()
{
RGB rgb1,rgb2,rgb;
int m,n;
cin>>rgb1>>rgb2;
cin>>m>>n;
rgb =rgb.RGBmix(rgb1,rgb2,m,n);
cout<<rgb<<endl;
return 0;
}
``````