[ create a new paste ] login | about

Link: http://codepad.org/IFXXoPGz    [ raw code | output | fork ]

C++, pasted on Feb 22:
#include <iostream>
using namespace std;

int main()
{
	double A[2][10];
	double x_arr[] = {1,2,3,4,10,6,4,8,9,-1};
	double y_arr[] = {1,2,3,4,10,6,5,8,9,-1};
	memcpy(&A[0], x_arr, sizeof(x_arr));
	memcpy(&A[1], y_arr, sizeof(y_arr));
	int nPoint = sizeof(A)/(2*sizeof(A[0][0]));
	bool bLine = true;
	for(int i  = 0; (i < nPoint) && bLine; i++)
	{
		cout<<"POINT # "<<i<<" ("<<A[0][i]<<";"<<A[1][i]<<") :\t";
		bLine = false;
		if(A[0][i])
		if(A[1][i] / A[0][i] == A[1][0] / A[0][0])//Как раз проверка угловых коэффициентов
			bLine = true;
		if(!bLine)
			cout<<"Point not lie in one line"<<endl;
		else
			cout<<"Point is in one line with previous points"<<endl;
	}
	return 0;
}


Output:
1
2
3
4
5
6
7
POINT # 0 (1;1) :	Point is in one line with previous points
POINT # 1 (2;2) :	Point is in one line with previous points
POINT # 2 (3;3) :	Point is in one line with previous points
POINT # 3 (4;4) :	Point is in one line with previous points
POINT # 4 (10;10) :	Point is in one line with previous points
POINT # 5 (6;6) :	Point is in one line with previous points
POINT # 6 (4;5) :	Point not lie in one line


Create a new paste based on this one


Comments: