#include <stdio.h>
#include <math.h>
#include <string.h>

typedef struct{
	double x;
	double y;
	double z;
	char name[20];
} Vector;

Vector VecProduct(Vector, Vector);
Vector VecMult(Vector, Vector);
double VecLenght(Vector);
void VecPrint(Vector);


int
main()
{
	Vector a = {
		12, 1, -0.9, "Alpha"
	};
	Vector b = {
		-2, 0.10, 18, "Beta"
	};
	Vector d = VecProduct(a, b);
	VecPrint(d);

	Vector e = VecMult(d, b);
	VecPrint(e);
	return 0;
}

Vector VecProduct(Vector a, Vector b)
{
	Vector c;
	c.x = a.x*b.x;
	c.y = a.y*b.y;
	c.z = a.z*b.z;
	strcpy(c.name, "product");
	return c;
}

Vector VecMult(Vector a, Vector b)
{
	Vector c;
	strcpy(c.name, "mult");
	c.x = a.y*b.z - a.z*b.y;
	c.y = a.z*b.x - a.x*b.z;
	c.z = a.x*b.y - a.y*b.x;
	return c;
}

double VecLenght(Vector c){
	return sqrt(c.x*c.x + c.y*c.y + c.z*c.z);
}

void VecPrint(Vector a){
	printf("Name:%s\n\tLen = %lf\n\tx = %lf\n\ty = %lf\n\tz = %lf\n", a.name, VecLenght(a), a.x, a.y, a.z);
}
