股票卖卖问题我是这样解的,Java。 void contextLoads() { double[] e = {1.0, 2.0, 1.0,2.0, 2.0, 3.0, 2.0}; double gold = 10000.0; double[] temp=new double[e.length]; for (int i = 1; i < e.length-3; i++) { double max1 = 0; double max2 = 0; for (int j = 0; j < i; j++) { if(max1 < e[i]/e[j]){ max1 = e[i]/e[j]; } } for (int z = i+1; z < e.length-1; z++) { for (int j = z+1; j < e.length; j++) { if(max2 < e[j]/e[z]){ max2 = e[j]/e[z]; } } } temp[i] = gold * max1 *max2; } for (int i = 0; i < e.length; i++) { // 最大值在temp里,遍历就行 System.out.println(temp[i]); } }
点赞 1

相关推荐

frutiger:逆天,我家就安阳的,这hr咋能说3k的,你送外卖不比这工资高得多?还说大厂来的6k,打发叫花子的呢?这hr是怎么做到说昧良心的话的
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务