Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- using namespace std;
- class Tline
- {
- private:
- float a,b,c;
- public:
- Tline()
- {
- a = 0;
- b = 0;
- c = 0;
- }
- Tline(float newa, float newb, float newc)
- {
- a = newa;
- b = newb;
- c = newc;
- }
- int printLine()
- {
- if((this->b>=0)&&(this->c>=0))
- cout<<this->a<<"x+"<<this->b<<"y+"<<this->c<<"=0"<<endl;
- else
- if((this->b<0)&&(this->c>0))
- cout<<this->a<<"x"<<this->b<<"y+"<<this->c<<"=0"<<endl;
- else
- if((this->c<0)&&(this->b>0))
- cout<<this->a<<"x+"<<this->b<<"y"<<this->c<<"=0"<<endl;
- else
- cout<<this->a<<"x"<<this->b<<"y"<<this->c<<"=0"<<endl;
- return 0;
- }
- bool checkDot(float x, float y)
- {
- return bool((this->a*x+this->b*y+c)==0);
- }
- };
- int main()
- {
- setlocale(LC_ALL,"RU");
- float a, b, c, x, y;
- cout<<"Введите коэффициенты уравнения прямой"<<endl;
- cout<<"a=";
- cin>>a;
- cout<<"b=";
- cin>>b;
- cout<<"c=";
- cin>>c;
- Tline *line = new Tline(a,b,c);
- line->printLine();
- cout<<"Введите координаты точки для проверки принадлежности к прямой"<<endl;
- cout<<"x=";
- cin>>x;
- cout<<"y=";
- cin>>y;
- cout<<line->checkDot(x,y);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement