如果我想用两个数组做除法,应该怎么实现
答案:1 悬赏:0 手机版
解决时间 2021-04-03 06:59
- 提问者网友:藍了天白赴美
- 2021-04-02 08:50
如果我想用两个数组做除法,应该怎么实现
最佳答案
- 五星知识达人网友:孤老序
- 2021-04-02 09:28
public static void main(String[] args) {
int[] a = {1,2,3,23,56,45,88};
int[] b = {3,2,3,23,56,45,88};
double[] c = new double[a.length];
for(int i = 0;iif(b[i] == 0){
return;
}
double s = (double)a[i]/b[i];
// DecimalFormat df = new DecimalFormat("#.00");
// System.out.println(df.format(s));
// c[i] = Double.valueOf(df.format(s));
// System.out.println(c[i]);
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(2);
System.out.println(nf.format(s));
c[i] = Double.parseDouble(nf.format(s));
}
}
int[] a = {1,2,3,23,56,45,88};
int[] b = {3,2,3,23,56,45,88};
double[] c = new double[a.length];
for(int i = 0;iif(b[i] == 0){
return;
}
double s = (double)a[i]/b[i];
// DecimalFormat df = new DecimalFormat("#.00");
// System.out.println(df.format(s));
// c[i] = Double.valueOf(df.format(s));
// System.out.println(c[i]);
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(2);
System.out.println(nf.format(s));
c[i] = Double.parseDouble(nf.format(s));
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯