解题思路:
注意事项:
参考代码:
package Year_2017;
import java.util.Scanner;
public class 观光铁路 {
private static int n,m;
private static int [] arr ;
private static int [] degree ;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m =sc.nextInt();
degree = new int [n];
arr = new int [n];
for(int i=0;i<m;i++) {
//记录各个城市的满意度
degree[sc.nextInt() - 1] ++;
degree[sc.nextInt() - 1] ++;
}
sc.close();
double totalDegree = 0;
for(int i=0;i<n;i++) {
totalDegree+=degree[i];
}
//===================================================================================
for(int i=0;i<n;i++) {
System.out.println(String.format("%.12f", totalDegree/degree[i]));
}
}
}
0.0分
1 人评分
【明明的随机数】 (C语言代码)浏览:785 |
【计算球体积】 (C语言代码)浏览:1101 |
Tom数 (C语言代码)浏览:492 |
整数平均值 (C语言代码)浏览:777 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:946 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:582 |
良心推荐——>题解1049:C语言程序设计教程(第三版)课后习题11.1 (C语言描述——简单明了,时间复杂度低)浏览:1273 |
生日日数 (C语言代码)浏览:1498 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:549 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:762 |