Problem Description
编一个程序,输入一个字符串,将组成字符串的所有非英文字母的字符删除后输出。
Input
一个字符串,长度不超过80个字符。
Output
删掉非英文字母后的字符串。
Example Input
abc123+xyz.5
Example Output
abcxyz
Hint
Author
ZJGSU
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();//数组用法
char[] ch = new char[1010];
int i, j;
for (i = 0; i < str.length(); i++) {
ch[i] = str.charAt(i);//获取str1中的第i个字符
}
for (j = 0; j <= i; j++) {
if ((ch[j] >= 'A' && ch[j] <= 'Z') || (ch[j] >= 'a' && ch[j] <= 'z'))
System.out.printf("%c", ch[j]);
}
System.out.println();
sc.close();
}
}