日期:2014-05-20 浏览次数:20711 次
import java.util.Scanner;
public class count {
public static void main(String[] args) {
int digital=0;
int character=0;
int other=0;
int blank=0;
char[] ch=null;
Scanner sc=new Scanner(System.in);
String s=sc.next();
ch=s.toCharArray();
for(int i=0;i<ch.length;i++){
if(ch[i]>='0'&&ch[i]<='9'){
digital++;
}
else if((ch[i]>='a'&&ch[i]<='z')||(ch[i]>='A'&&ch[i]<='Z')){
character++;
}
else if(ch[i]==' '){
blank++;
}
else{
other++;
}
}
System.out.println("shuzi="+digital+"character="+character+"other="+other+"blank="+blank);
}
}