第十二周java作业
package fff; public class test { public static void main(String[] args) { String str = "Hello World"; char[] c = str.toCharArray(); StringBuffer buffer = new StringBuffer(); for (int i = str.length() - 1; i >= 0; i--) { if ((c[i] >= 'A') && (c[i] <= 'Z')) { buffer.append(String.valueOf(c[i]).toLowerCase()); } else if ((c[i] >= 'a') && (c[i] <= 'z')) { buffer.append(String.valueOf(c[i]).toUpperCase()); } } System.out.println(buffer.toString()); } }
package fff; import java.util.Random; public class test { public static void main(String[] args) { Random rand = new Random(); int[] num = new int[5]; for (int i=0; i<num.length; i++) { num[i] = 20 + rand.nextInt(31); System.out.println(num[i]); } } }