第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何將數(shù)組列表值返回到單獨(dú)的數(shù)組中?

如何將數(shù)組列表值返回到單獨(dú)的數(shù)組中?

ibeautiful 2021-04-09 18:15:28
我正在嘗試創(chuàng)建一個(gè)程序來(lái)獲取兩個(gè)向量的點(diǎn)積。我通過(guò)創(chuàng)建一個(gè)數(shù)組列表(命名距離)來(lái)實(shí)現(xiàn)它。通過(guò)在main方法中更改此行,可以使該程序使用硬編碼數(shù)字運(yùn)行。double vect_A[] = distnace(mag);double vect_B[] = distance(dista);我知道上面的代碼無(wú)法運(yùn)行,是否可以將這些特定值返回到單獨(dú)的數(shù)組中?還是我錯(cuò)誤地解決了這個(gè)問(wèn)題。我對(duì)Java非常陌生,將不勝感激。//java implementation for dot product// and cross product of two vector.import java.util.Scanner;import java.util.ArrayList;class practiceMats {    public static void main (String[] args) {        vector();        double vect_A[] = distnace(mag);        double vect_B[] = distance(dista);        // dotProduct function call        System.out.print ( "Dot product:");        System.out.println (dotProduct(vect_A, vect_B)) ;    }    static double n = 3.0;    // Function that return    // dot product of two vector array.    static double dotProduct(double vectorA[], double vectorB[])    {             double product = 0.0;        // Loop for calculate cot product        for (int i = 0; i < n; i++)            product = product + vectorA[i] * vectorB[i];        return product;    }    static ArrayList<Integer> vector()     {        ArrayList<Integer>distance= new ArrayList<Integer>();          Scanner scan = new Scanner (System.in);        System.out.println("Please enter your array length: ");        int s = Integer.parseInt(scan.nextLine());        System.out.println();        for(int i = 0; i < s; i++) {            System.out.println("Enter your distance: ");            int dista = Integer.parseInt(scan.nextLine());            distance.add(dista);             System.out.println("Enter your distance: ");            int mag = Integer.parseInt(scan.nextLine());            distance.add(mag);         }        return distance;    }}
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 229 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)