// 1a.cpp
#include <iostream>
#include <iomanip>
using namespace std;
typedef struct {
float x;
float y;
} Vector;
typedef struct {
Vector paso;
Vector direccion;
} Recta;
void inicializar(Recta* ptr, int cap);
void mostrar(Recta* ptr, int cap);
int main() {
srand(time(nullptr));
int n=0;
// introduza el valor de n
cout<<"n\t:\t";
cin>>n;
// iniciliza el arreglo dinámico
Recta* ptr = nullptr;
ptr = new Recta [n];
inicializar(ptr, n);
mostrar(ptr, n);
delete [] ptr;
}
void inicializar(Recta* ptr, int cap) {
for(int j=0; j<cap; ++j) {
ptr[j].paso.x = rand()%3;
ptr[j].paso.y = rand()%3;
ptr[j].direccion.x = rand()%3;
ptr[j].direccion.y = rand()%3;
if(ptr[j].direccion.x == 0 && ptr[j].direccion.y == 0)
ptr[j].direccion.x += 1;
}
}
void mostrar(Recta* ptr, int cap) {
cout<<"Recta\t\tRepresentacion vectorial\n";
double m=0;
for(int j=0; j<cap; j++) {
cout<<setw(3)<<j<<"\t\t";
if(ptr[j].direccion.x == 0){
cout<<ptr[j].direccion.y<<"x + (";
cout<<ptr[j].paso.x * ptr[j].direccion.y<<") = 0";
}else{
m = ptr[j].direccion.y/ptr[j].direccion.x;
cout<<m<<"x - y + (";
cout<<ptr[j].paso.y - m*ptr[j].paso.x<<") = 0";
}
cout<<endl;
}
}