#include <stdio.h> #include <string.h> int main() { char str[200]; int z = 0, s = 0, k = 0, q = 0; gets(str); for (int i = 0; i < strlen(str); i++) { if (('a' <= str[i] && str[i] <= 'z') || ('A' <= str[i] && str[i] <= 'Z')) { z++; } else if ('0' <= str[i] && str[i] <= '9') { s++; } else if (str[i] == ' ') { k++; } else { q++; } } printf("%d %d %d %d", z, s, k, q); return 0; }
import java.util.Scanner; public class Main{ public static void main(String[] args) { int z=0,s=0,k=0,q=0; Scanner sc=new Scanner(System.in); String c=sc.nextLine(); char[] str=c.toCharArray(); for(int i=0;i<=str.length-1;i++) { if(Character.isLetter(str[i])) { z++; }else if(Character.isDigit(str[i])) { s++; }else if(Character.isSpaceChar(str[i])) { k++; }else { q++; } } System.out.println(z+" "+s+" "+k+" "+q); } }
0.0分
1 人评分