求完整程序,包括建立无向图,任选两点,计算最短路径。用java编写的 最好有个别注释,谢谢! 20
2个回答
展开全部
package com.baidu.zhidao;
public class Cat {
public static void main(String[] args) {
double[] scores = ;
double sum = calcSum(scores);
double avg = calcAvg(scores);
System.out.println(sum);
System.out.println(avg);
}
private static double calcAvg(double[] scores) {
return calcSum(scores) / scores.length;
}
private static double calcSum(double[] scores) {
double sum = 0;
for (int i = 0; i < scores.length; i++) {
sum += scores[i];
}
return sum;
}
}
public class Cat {
public static void main(String[] args) {
double[] scores = ;
double sum = calcSum(scores);
double avg = calcAvg(scores);
System.out.println(sum);
System.out.println(avg);
}
private static double calcAvg(double[] scores) {
return calcSum(scores) / scores.length;
}
private static double calcSum(double[] scores) {
double sum = 0;
for (int i = 0; i < scores.length; i++) {
sum += scores[i];
}
return sum;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询