1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <iostream>
#include <cmath>
using namespace std;
void linear (double ,double,double,double,double&,double&);
int main()
{
double x,y,cord1,cord2,slope,intercept;
do {
cout<<"Enter two points for a line:\n";
cin>>x>>y;
cout<<"Enter two points for the same line:\n";
cin>>cord1,cord2;
}
while(x==cord1);
cout<<"This is a vertical line,";
cout<<"The equation is:"<<x<<"="<<cord1;
if (cord1!==x)
linear(x,y,cord1,cord2,slope,intercept);
cout<<"The slope of your coordinates are: "<<slope;
return 0;
}
void linear (double n1, double n2,double n3, double n4,double&slopes,double&inter)
{
slopes= (n4-n2)/(n3-n1);
inter=(n2=(slopes)(n3))
}
|