013 l2 guruh talabsi Boymatov Elbek 6-Laboratoriya ishi
Download 59.4 Kb.
|
6-lab
- Bu sahifa navigatsiya:
- Topshiriq №2
013_l2 guruh talabsi Boymatov Elbek 6-Laboratoriya ishi Sonli klasslar Topshiriq №1 Complex sinfidan foydalanib, ikkita kompleks sonlarni ayiring #include #include using namespace std; //**********COMPLEX CLASS************************ class Complex{ private:
double real,imag; public:
Complex(){ real=imag=0; } Complex(double r){ real=r; imag=0;
} Complex(double r, double i){ real=r; imag=i;
} Complex(Complex &obj){ real=obj.real; imag=obj.imag; } Complex add(Complex c){ Complex Add; Add.real = real + c.real; Add.imag = imag + c.imag; return Add; } Complex sub(Complex c){ Complex Sub; Sub.real = real - c.real; Sub.imag = imag - c.imag; return Sub; } void print(){ cout< } double getReal() const{ return real; } double getImag() const{ return imag; } void setReal(double re){ real = re; } void setImag(double im){ imag = im; } }; int main() { double real1,imag1,real2,imag2; cout<<"Birinchi raqamning haqiqiy qismini kiriting: "; cin>>real1; cout<<"Birinchi raqamning mavhum qismini kiriting: "; cin>>imag1; Complex obj1(real1,imag1); obj1.print(); cout<<"Ikkinchi raqamning haqiqiy qismini kiriting: "; cin>>real2; cout<<"Ikkinchi raqamning mavhum qismini kiriting: "; cin>>imag2; Complex obj2(real2,imag2); obj2.print(); Complex c; c = obj1.add(obj2); cout<<"ikkita complex sonni qoshish : ("< c= obj1.sub(obj2); cout< return 0; #include #include using namespace std; void show(valarray for(int i=0; i cout<
}
} {
while (i < n && j < n) {
if (var1[i] < var2[j]) cout << var1[i]<<" "; i++;
}
{
j++;
else
i++;
}
}
{
valarray for(int i=0; i<10; i++){
varr1[i]=rand()%15-5; varr2[i]=rand()%15-5;
}
cout<<"Birinchi valarray: "; cout<<"\nIkkinchi Valarray: "; show(varr2, 10); cout<<"\n\nIkkita massivning farqi: \n"; arrayDiff(varr1,varr2,10); return 0; } Download 59.4 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling