카타 7급 Cross Product of Vectors

C[ | ]

#include <stdlib.h>
double *crossprod(const double *v1, const double *v2, size_t len1, size_t len2)
{
  if( v1==NULL || v2==NULL || len1!=3 || len2!=3 ) return NULL;
  double* res = malloc(3 * sizeof(double));
  res[0] = v1[1]*v2[2] - v1[2]*v2[1];
  res[1] = v1[2]*v2[0] - v1[0]*v2[2];
  res[2] = v1[0]*v2[1] - v1[1]*v2[0];
  return res;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}