作者:梧桐树信息科技 | 来源:互联网 | 2023-05-19 07:02
IamstilllearningJavaandhaveaquestiononanarray.我还在学习Java并对数组有疑问。Myarray:doublearr[
I am still learning Java and have a question on an array.
我还在学习Java并对数组有疑问。
My array:
double arr[] = {1.8, 3.6, 5.0, 2.0};
My question is how do I divide the first index by the next and so on, but not the last index. Each index is to be divided by 2. So that the resulting array looks like this:
我的问题是如何将第一个索引除以下一个等等,而不是最后一个索引。每个索引除以2.因此生成的数组如下所示:
double arr[] = {0.5, 0.72, 2.5, 2.0};
I am on the right track by proceeding this way:
通过这种方式我走在正确的轨道上:
public static void main(String [] args){
double arr[] = {1.8, 3.6, 5.0, 2.0};
for(int j = 0; j
I am not sure how to proceed and all help is appreciated.
我不知道如何继续,所有的帮助表示赞赏。
Thank you.
3 个解决方案