Upload batch 131/306
Browse files- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 4/Lab04.zip +3 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 4/Lab4 plus.pdf +3 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 5/Lab5.pdf +3 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 5/פתרון חלקית למעבדה 05-20241023/Rational.cpp +64 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 5/פתרון חלקית למעבדה 05-20241023/Rational.h +25 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 5/פתרון חלקית למעבדה 05-20241023/test.cpp +14 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 6/Lab6.pdf +3 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 6/פתרון חלקי למעבדה 06-20241023/Complex.cpp +78 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 6/פתרון חלקי למעבדה 06-20241023/Complex.h +47 -0
- שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 6/פתרון חלקי למעבדה 06-20241023/test06.cpp +30 -0
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 4/Lab04.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:167c7c812af9c331482e0567b04c7f710367ef5a9c01b336cecaccd295adbdbe
|
| 3 |
+
size 2051
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 4/Lab4 plus.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f120d0837b45667bfa981ee3c54f93665c7ad58eb7b830d545a8f9e875ee75cf
|
| 3 |
+
size 555604
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 5/Lab5.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:473aa685112d557b8cdd9fe0289b78855beeec6970c598e960511ac5c5dc3f08
|
| 3 |
+
size 132582
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 5/פתרון חלקית למעבדה 05-20241023/Rational.cpp
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include "Rational.h"
|
| 2 |
+
#include <iostream>
|
| 3 |
+
using namespace std;
|
| 4 |
+
|
| 5 |
+
int Rational::GetNumerator() const{
|
| 6 |
+
return this->numerator;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
int Rational::GetDenomerator() const{
|
| 10 |
+
return this->denomerator;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
void Rational::SetNumerator(int numerator){
|
| 14 |
+
this->numerator=numerator;
|
| 15 |
+
this->reduce();
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
void Rational::SetDenomerator(unsigned int denomerator){
|
| 19 |
+
this->denomerator=denomerator>0 ? denomerator : 1;
|
| 20 |
+
this->reduce();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
Rational::Rational(int numerator, int denomerator)
|
| 24 |
+
:numerator(numerator){
|
| 25 |
+
SetDenomerator(denomerator);
|
| 26 |
+
this->reduce();
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
ostream &operator<<(ostream &out, const Rational &r){
|
| 30 |
+
out<< r.GetNumerator() << "/" << r.GetDenomerator();
|
| 31 |
+
return out;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
void Rational::reduce(){
|
| 35 |
+
int a=numerator, b=denomerator;
|
| 36 |
+
if(a<b){ int t=a; a=b; b=t;}
|
| 37 |
+
while(b){
|
| 38 |
+
int t=a%b;
|
| 39 |
+
a=b;
|
| 40 |
+
b=t;
|
| 41 |
+
}
|
| 42 |
+
numerator/=a;
|
| 43 |
+
denomerator/=a;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
Rational & Rational::operator+(const Rational &r) const {
|
| 47 |
+
Rational *tmp=new Rational(this->numerator*r.GetDenomerator()
|
| 48 |
+
+ this->denomerator *r.GetNumerator(),
|
| 49 |
+
this->denomerator*r.GetDenomerator());
|
| 50 |
+
tmp->reduce();
|
| 51 |
+
return *tmp;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
Rational & Rational::operator+(const int &x) const{
|
| 55 |
+
Rational *tmp=
|
| 56 |
+
new Rational(this->numerator*x,this->denomerator);
|
| 57 |
+
tmp->reduce();
|
| 58 |
+
return *tmp;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
Rational & operator+(const int &x, const Rational &r){
|
| 62 |
+
return r+x;
|
| 63 |
+
}
|
| 64 |
+
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 5/פתרון חלקית למעבדה 05-20241023/Rational.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
#include <iostream>
|
| 3 |
+
using namespace std;
|
| 4 |
+
|
| 5 |
+
class Rational{
|
| 6 |
+
friend ostream& operator<<(ostream &, const Rational &);
|
| 7 |
+
// r3=x+r1
|
| 8 |
+
friend Rational & operator+(const int &, const Rational &);
|
| 9 |
+
public:
|
| 10 |
+
Rational(int, int);
|
| 11 |
+
Rational():numerator(0), denomerator(1){}
|
| 12 |
+
int GetNumerator() const;
|
| 13 |
+
int GetDenomerator() const;
|
| 14 |
+
void SetNumerator(int );
|
| 15 |
+
void SetDenomerator(unsigned int );
|
| 16 |
+
// Rational r1, r2, r3; int x;
|
| 17 |
+
Rational & operator+(const Rational &) const; // r3=r1+r2
|
| 18 |
+
Rational & operator+(const int &) const; // r3=r1+x
|
| 19 |
+
void reduce();
|
| 20 |
+
private:
|
| 21 |
+
int numerator;
|
| 22 |
+
unsigned int denomerator;
|
| 23 |
+
|
| 24 |
+
};
|
| 25 |
+
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 5/פתרון חלקית למעבדה 05-20241023/test.cpp
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <iostream>
|
| 2 |
+
using namespace std;
|
| 3 |
+
#include "Rational.h"
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
void main(){
|
| 7 |
+
Rational r1(3,9), r2(12,42), r3;
|
| 8 |
+
int ix=5;
|
| 9 |
+
cout<< r1 << endl << r2 << endl;
|
| 10 |
+
cout<< r1 << "+" << r2 << "=" << r1+r2 << endl;
|
| 11 |
+
cout<< r1 << "+" << ix << "=" << r1+ix << endl;
|
| 12 |
+
cout<< ix << "+" << r1 << "=" << r1+ix << endl;
|
| 13 |
+
system("pause");
|
| 14 |
+
}
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 6/Lab6.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7fc9ca00e5010b3c49fa91224314dd6a0e924224db1e01604defdc05695b7bb0
|
| 3 |
+
size 528932
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 6/פתרון חלקי למעבדה 06-20241023/Complex.cpp
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <iostream>
|
| 2 |
+
#include "Complex.h"
|
| 3 |
+
using namespace std;
|
| 4 |
+
|
| 5 |
+
double Complex::GetReal()const {
|
| 6 |
+
return this->real;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
double Complex::GetImaging() const{
|
| 10 |
+
return this->imaging;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
void Complex::SetReal(double real){
|
| 14 |
+
this->real=real;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
void Complex::SetImaging(double imaging){
|
| 18 |
+
this->imaging=imaging;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// operators class member
|
| 22 |
+
void Complex::operator+=(const Complex &c){
|
| 23 |
+
this->real+=c.GetReal();
|
| 24 |
+
this->imaging+=c.GetImaging();
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
void Complex::operator*=(const Complex &c){
|
| 28 |
+
this->real=this->real*c.GetReal()
|
| 29 |
+
- this->imaging*c.GetImaging();
|
| 30 |
+
this->imaging=this->real*c.GetImaging()
|
| 31 |
+
+imaging*c.GetReal();
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
const Complex& Complex::operator+(const Complex &c) const{
|
| 35 |
+
Complex *answ=new Complex();
|
| 36 |
+
answ->SetReal(this->GetReal()+c.GetReal());
|
| 37 |
+
answ->SetImaging(this->GetImaging()+
|
| 38 |
+
c.GetImaging());
|
| 39 |
+
return *answ;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
const Complex& Complex::operator+(const double d)const{
|
| 43 |
+
Complex *answ=new Complex();
|
| 44 |
+
answ->SetReal(this->GetReal()+d);
|
| 45 |
+
answ->SetImaging(this->GetImaging());
|
| 46 |
+
return *answ;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
const Complex& Complex::operator*(const Complex &c) const{
|
| 50 |
+
return *(new Complex(
|
| 51 |
+
this->real*c.GetReal()
|
| 52 |
+
- this->imaging*c.GetImaging(),
|
| 53 |
+
this->real*c.GetImaging()
|
| 54 |
+
+ this->imaging*c.GetReal()
|
| 55 |
+
));
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
const Complex& Complex::operator*(const double d) const{
|
| 59 |
+
return *(new
|
| 60 |
+
Complex(this->real*d, this->imaging*d));
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
// operators public member
|
| 64 |
+
ostream &operator<<(ostream &print, const Complex &c){
|
| 65 |
+
print<<c.GetReal();
|
| 66 |
+
if(c.GetImaging()>0)
|
| 67 |
+
print<<" + ";
|
| 68 |
+
print<<c.GetImaging()<<"i";
|
| 69 |
+
return print;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
const Complex & operator+(const double d, const Complex &c){
|
| 73 |
+
return c+d;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
const Complex& operator*(const double d, const Complex &c){
|
| 77 |
+
return c*d;
|
| 78 |
+
}
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 6/פתרון חלקי למעבדה 06-20241023/Complex.h
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
#include <iostream>
|
| 3 |
+
using namespace std;
|
| 4 |
+
|
| 5 |
+
class Complex{
|
| 6 |
+
public:
|
| 7 |
+
Complex(double real=0,double imaging=0)
|
| 8 |
+
:real(real), imaging(imaging){};
|
| 9 |
+
double GetReal() const;
|
| 10 |
+
double GetImaging() const;
|
| 11 |
+
void SetReal(double);
|
| 12 |
+
void SetImaging(double);
|
| 13 |
+
// operators class members
|
| 14 |
+
void operator+=(const Complex &);
|
| 15 |
+
const Complex & operator+(const Complex &) const;
|
| 16 |
+
const Complex & operator+(const double ) const;
|
| 17 |
+
void operator*=(const Complex &);
|
| 18 |
+
const Complex & operator*(const Complex &) const;
|
| 19 |
+
const Complex & operator*(const double ) const;
|
| 20 |
+
|
| 21 |
+
// operators friend
|
| 22 |
+
friend ostream & operator<<(ostream &, const Complex &);
|
| 23 |
+
friend const Complex & operator+(const double, const Complex &);
|
| 24 |
+
friend const Complex & operator*(const double, const Complex &);
|
| 25 |
+
|
| 26 |
+
private:
|
| 27 |
+
double real;
|
| 28 |
+
double imaging;
|
| 29 |
+
};
|
| 30 |
+
/*
|
| 31 |
+
Complex c1( 1.0, -4.0 );
|
| 32 |
+
Complex c2( 15.0, 1.0 );
|
| 33 |
+
Complex c3 = c1 + c2;
|
| 34 |
+
c2 += c1;
|
| 35 |
+
c2 *= c1;
|
| 36 |
+
c2 /= c1;
|
| 37 |
+
c2 -= c1;
|
| 38 |
+
c3 = c1 + c2;
|
| 39 |
+
c3 = c1 - c2;
|
| 40 |
+
c3 = c1 * c2;
|
| 41 |
+
c3 = c1 / c2;
|
| 42 |
+
double d=5.0;
|
| 43 |
+
c2=d*c1;
|
| 44 |
+
c2=c1*d;
|
| 45 |
+
c2=d/c1;
|
| 46 |
+
c2=c1/d;
|
| 47 |
+
*/
|
שנה א/תכנות מונחה עצמים/מעבדה/מעבדה 6/פתרון חלקי למעבדה 06-20241023/test06.cpp
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <iostream>
|
| 2 |
+
#include "Complex.h"
|
| 3 |
+
using namespace std;
|
| 4 |
+
|
| 5 |
+
void main(){
|
| 6 |
+
Complex c1( 1.0, -4.0 );
|
| 7 |
+
Complex c2( 15.0, 1.0 );
|
| 8 |
+
cout<<"before calculation"<<endl;
|
| 9 |
+
cout<<"c1= "<<c1<<endl<<"c2= "<<c2<<endl;
|
| 10 |
+
cout<<"after calculation"<<endl;
|
| 11 |
+
Complex c3 = c1 + c2;
|
| 12 |
+
cout<< "c3=" << c1 << "+" << c2 << "+";
|
| 13 |
+
cout<<c3 << endl;
|
| 14 |
+
c2 += c1;
|
| 15 |
+
cout<<"c2= "<<c2<<endl;
|
| 16 |
+
cout<< c1 <<"*" << c2 << "+"
|
| 17 |
+
<< c1*c2 << endl;
|
| 18 |
+
double d=5.0;
|
| 19 |
+
c2=d+c1;
|
| 20 |
+
cout<<"c2="<<d<<"+"<<c1<<"= ";
|
| 21 |
+
cout<<c2<<endl;
|
| 22 |
+
c2=c1+d;
|
| 23 |
+
cout<<"c2="<<c1<<"+"<<d<<"= ";
|
| 24 |
+
cout<<c2<<endl;
|
| 25 |
+
cout<< "("<< c1 << ")"<<"*" << d << "="
|
| 26 |
+
<< c1*d << endl;
|
| 27 |
+
cout<< d <<"*" << "("<< c1 << ") ="
|
| 28 |
+
<< d*c1 << endl;
|
| 29 |
+
system("pause");
|
| 30 |
+
}
|