UHGMYNTOI~LPY~$OP{XI`30.png (55.96 KB, 下载次数: 16)
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个字符串:");
String str = sc.nextLine();
char[] arr = new char[str.length()];
for (int i = 0; i < str.length(); i++) {
arr = str.charAt(i);
}
for (int i = 0; i < arr.length; i++) {
if (arr >= 'A' && arr <= 'Z') {
arr = (char) (arr + 32);
}
}
if (arr[0] != arr[arr.length - 1]) {
char temp = arr[0];
arr[0] = arr[arr.length - 1];
arr[arr.length - 1] = temp;
}
for (int i = 0; i < arr.length; i += 2) {
arr = '~';
}
for (int i = 0; i < arr.length; i++) {
System.out.print(arr + ", ");
}
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |