解题思路:
import java.io.*; public class Main { public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); public static StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); public static PrintWriter cout = new PrintWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws Exception { String s = in.readLine(); char[] ch = s.toCharArray(); int a = 0, b = 0, c = 0, d = 0; for (int i = 0; i < ch.length; i++) { if ((ch[i] >= 'a' && ch[i] <= 'z') || (ch[i] >= 'A' && ch[i] <= 'Z')) { a++; } else if (ch[i] >= '0' && ch[i] <= '9') { b++; } else if (ch[i] == ' ') { c++; } else { d++; } } cout.printf("%d %d %d %d", a, b, c, d); cout.flush(); } }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:628 |
矩阵加法 (C语言代码)浏览:1768 |
A+B for Input-Output Practice (VII) (C语言代码)浏览:566 |
sizeof的大作用 (C语言代码)浏览:1138 |
C二级辅导-温度转换 (C语言代码)浏览:802 |
C语言程序设计教程(第三版)课后习题8.2 (C语言代码)浏览:1108 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:856 |
【出圈】 (C++代码)简单循环浏览:699 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:538 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:548 |