给定两个三维向量,你需要求出这两个向量的叉乘的结果。 你需要实现一个函数,接受两个参数,均为由三个整数构成的向量。你需要计算出这两个向量叉乘的结果,并将这个结果作为该函数的返回值。
示例1
输入
[1,0,1],[0,1,0]
输出
[-1,0,1]
备注:
数据保证各个向量的坐标的绝对值均小于 。
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型ArrayList */ public ArrayList
crossTimes (int[] vector1, int[] vector2) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型vector * @param vector2 int整型vector * @return int整型vector */ vector
crossTimes(vector
& vector1, vector
& vector2) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 计算出这两个向量叉乘的结果 # @param vector1 int整型一维数组 # @param vector2 int整型一维数组 # @return int整型一维数组 # class Solution: def crossTimes(self , vector1 , vector2 ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ public List
crossTimes (List
vector1, List
vector2) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ function crossTimes( vector1 , vector2 ) { // write code here } module.exports = { crossTimes : crossTimes };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 计算出这两个向量叉乘的结果 # @param vector1 int整型一维数组 # @param vector2 int整型一维数组 # @return int整型一维数组 # class Solution: def crossTimes(self , vector1: List[int], vector2: List[int]) -> List[int]: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ func crossTimes( vector1 []int , vector2 []int ) []int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector1Len int vector1数组长度 * @param vector2 int整型一维数组 * @param vector2Len int vector2数组长度 * @return int整型一维数组 * @return int* returnSize 返回数组行数 */ int* crossTimes(int* vector1, int vector1Len, int* vector2, int vector2Len, int* returnSize ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 计算出这两个向量叉乘的结果 # @param vector1 int整型一维数组 # @param vector2 int整型一维数组 # @return int整型一维数组 # class Solution def crossTimes(vector1, vector2) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ def crossTimes(vector1: Array[Int],vector2: Array[Int]): Array[Int] = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ fun crossTimes(vector1: IntArray,vector2: IntArray): IntArray { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ public int[] crossTimes (int[] vector1, int[] vector2) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ export function crossTimes(vector1: number[], vector2: number[]): number[] { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ func crossTimes ( _ vector1: [Int], _ vector2: [Int]) -> [Int] { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算出这两个向量叉乘的结果 * @param vector1 int整型一维数组 * @param vector2 int整型一维数组 * @return int整型一维数组 */ pub fn crossTimes(&self, vector1: Vec
, vector2: Vec
) -> Vec
{ // write code here } }
[1,0,1],[0,1,0]
[-1,0,1]