题解 | 向量点乘

向量点乘

https://www.nowcoder.com/practice/f043b2390788458db7762300911e30df

三维向量点乘即为对应位置的数的积相加的和,使用for循环遍历即可.


    int dotTime(vector<int>& vector1, vector<int>& vector2) {
        int ans=0;
        for(int i=0;i<3;i++){
            ans+=vector1[i]*vector2[i];
        }
        return ans;
        // write code here
    }

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务