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