解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); String n=scanner.nextLine(); char a[]=n.toCharArray(); int word=0,digit=0,space=0,other=0; for(int i=0;i<a.length;i++) { if(Character.isLetter(a[i])) word++; else if(Character.isDigit(a[i])) digit++; else if(a[i]==' ') space++; else other++; } System.out.print(word+" "+digit+" "+space+" "+other); } }
0.0分
0 人评分
C二级辅导-阶乘数列 (C语言代码)浏览:831 |
【绝对值排序】 (C语言代码)浏览:482 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:466 |
众数问题 (C语言代码)浏览:3514 |
C语言训练-自守数问题 (C语言代码) long long浏览:1066 |
【数组的距离】 (C语言代码)浏览:738 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:648 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)from DQM浏览:666 |
A+B for Input-Output Practice (V) (C语言代码)浏览:466 |
【偶数求和】 (C语言代码)浏览:431 |