/** *Created by xuzili at 22:12 on 2018/4/4 */ // 以上注释使用了IntelliJ Idea的File-Settings-Editor-Live Templates-User(Self)提供的/*a+tab键(自定义功能) import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in)…
package com.c2; import java.util.Random; import java.util.Scanner; //输入10个数,找出最大一个数,并打印出来. public class IO { public static void main(String[] args) { Scanner c = new Scanner(System.in); System.out.println("请输入3个数------"); int b = c.nextInt(); in…
需求说明: 定义两个方法,在控制台输入一个数字,这两个方法可以求出1到该数字之间所有偶数之和.奇数之和,并将对应结果和返回.在main方法中调用该方法,并在控制台打印出结果.(有参数有返回值方法) 运行效果如图所示: 实现思路: import java.util.Scanner; import javax.xml.soap.Text; public class EvenOdd { public static int even(int num,int sum) { System.out.print…
//求n个数中的最小k个数 public static void TestMin(int k, int n) { Random rd = new Random(); int[] myArray = new int[n]; int[] newArray = new int[k]; for (int i = 0; i < n; i++) { // rand…
总结:1.谢谢程老师,一个很好的老师,人很普通,但是浑浊的世界里,那一份真实感动到底~~~~很感谢他 2.这里注意两个方面,也是我最大的弱点:循环和数组的length属性.前者运用不灵活,后者自己总是不能理解.很桑心啦~~~~ package com.c2; public class DD { // 求数组的平均值即 :a[i]/a.length public static double getAva(int a[]) { double s = 0; for (int i = 1; i < a.…
真是学了后面忘了前面,一维数组都忘了 package com.c2; //总结类型转换不对,导致运行报错 //以及没有new,导致空指针异常 //引入流. import java.io.*; public class Col { private String name; private float weight; public void setName(String b) { name = b; } public String getName() { return name; } public…
Life Forms Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, eyebrows and the like. A few bear no human resemblance; these typically have…
# 看题目是不是很绕,这个我也不知道怎么才能更简单的表达了... # 先看代码: public class Common { public static void main(String[] args) { Sub sub = new Sub(); sub.testSub(); } } class Parent { protected boolean test() { throw new RuntimeException(); } protected void testParent() { if…