} } 运行结果贴图: (6)建立一个不规则的二维数组如下,并在控制台显示,数组如下 1 3 5 2 4 6 8 1 9 16 25 36 10 20 30 1 2 3 4 5 6 程序代码: public class LX3_10 { public static void main(String[] args) { int[][] new1 = { { 1, 3, 5 }, { 2, 4, 6, 8 }, { 1, 9, 16, 25, 36 }, } { 10, 20, 30 }, { 1, 2, 3, 4, 5, 6 } }; for (int i = 0; i < 5; i++) { for (int j = 0; j < new1[i].length; j++) { } System.out.println(); System.out.printf(\, new1[i][j]);
} } 运行结果贴图: (7)编写两个重载的方法分别交换两个整型变量,和整型数组的第一个和第二个元素,运行并分析结果 程序代码: public class LX3_11 { public static void Switch(int a, int b) { int t; t = a; a = b; b = t; System.out.println(\交换以后:\); public static void main(String[] args) { } int a = 2, b = 5; int[] c = { 2, 5}; Switch(a, b); Switch(c);
} } System.out.println(\ + a + \ + b); public static void Switch(int[] a) { } int t; t = a[0]; a[0] = a[1]; a[1] = t; System.out.println(\ + a[0] + \ + a[1]); 运行结果贴图: 课后作业题 P153 5.16 5.23 5.25 P184 6.13 P186 6.26 P202 7.1 7.2 7.6 7.23* 5.16 程序代码: public class LX3_12 { public static void main(String[] args) {
} } for (int i = 2000; i <= 2010; i++) { } System.out.println(i + \年的天数是\ + numberOfDaysInYear(i)); public static int numberOfDaysInYear(int year) { } if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) { } return 366; return 365; } else { 运行结果贴图: 5.23 程序代码: public class LX3_13 { public static void main(String[] args) { System.out.println(\个大写字母:\); SysOut('A', 'Z');
} } System.out.println(\个一位数:\); SysOut('0', '9'); public static char getRandomCharacter(char ch1, char ch2) { } public static void SysOut(char zf1, char zf2) { } for (int i = 0; i < 10; i++) { } for (int j = 0; j < 10; j++) { } System.out.println(); System.out.printf(\, getRandomCharacter(zf1, zf2)); return (char) (ch1 + Math.random() * (ch2 - ch1 + 1)); 运行结果贴图: 5.25 程序代码:
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库实验3 方法和数组(3)在线全文阅读。
相关推荐: