实验内容及步骤:
(1)代码: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world!"); } } (2)运行结果:
(1)代码: public class TestTravel { public static void main(String[] args) { int[]arr01=new int[10]; for (int i=0;i<arr01.length-1;i++) { arr01[i]=i+1; } for (int i=0;i<=arr01.length-1;i++) { if(arr01[i]%3==0) { | |
实验内容及步骤: System.out.println("arr01[" + i + "]=" + arr01[i]); } } } } (2)运行结果:
(1)代码: public class TestNum { public static void main(String[] args) { //水仙花数 for(int n = 100;n < 1000;n ++) { int i = n / 100; int j = n / 10 % 10; int k = n % 10; if(Math.pow(i,3) + Math.pow(j,3) + Math.pow(k,3) == n) { System.out.println(n + "是水仙花数"); } } } } (2)运行结果: | |
实验内容及步骤:
(1)代码: public class Area { public static void main(String[] args) { double r=3; double a=5; double b=12; System.out.println("圆的面积:"+area(r)); System.out.println("长方形的面积:"+area(a,b)); } static double area(double r) { return Math.PI*r*r; } static double area(double a,double b) { return a*b; } } (2)运行结果: | |
你的问题:
|