十二周作业

package bwk;

public class Hnil {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        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 bwk;
import java.util.Random;
public class Hnil {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        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]);
        }

    }

}

posted @ 2020-05-26 11:02  Happy_Virus  阅读(93)  评论(0编辑  收藏  举报