0
点赞
收藏
分享

微信扫一扫

c语言 向量点积

黄昏孤酒 2022-02-11 阅读 71

在这里插入图片描述

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

typedef struct point {
    int x;
    int y;
} Vector;

int vector_dotprod(Vector v1, Vector v2) {
    
    return v1.x * v2.x + v1.y * v2.y;
}

int main() {
    
    Vector v1;
    Vector v2;
    int dotprod_result;

    scanf("%d%d", &(v1.x), &(v1.y));
    scanf("%d%d", &(v2.x), &(v2.y));

    dotprod_result = vector_dotprod(v1, v2);
	printf("%d", dotprod_result);
	
	return 0;
}
举报

相关推荐

0 条评论