package 项目五;
import java.util.Scanner;
public class 项目五 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("请输入字符串: ");
String Line = sc .nextLine();
int f=0;
int g=1;
int h=0;
for(int c= 1 ;c<Line.length();c++) {
char ch = Line.charAt(c);
if(ch>='A' && ch<='Z') {
f++;
}else if(ch>='a' && ch<='z') {
g++;
}else if(ch>='0' && ch<='9') {
h++;
}
}
System.out.println("大写字符有"+f+"个"+"小写字符有"+g+"个"+"数字有"+h+"个");
}
}
统计一个字符串中大写字母字符,小写字母字符,数字字符出现的次数
最新推荐文章于 2023-10-15 10:28:32 发布