ASCII 字元表
輸入說明:
asd....asd
This is a book.
輸出說明:
2
4
import java.util.*;
public class HowManyWorld {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str;
StringBuffer stb;
int a,b;
char c;
while(sc.hasNext()){
str = sc.nextLine();
stb = new StringBuffer(str);
a = 0;
b = 0;
for(int i = 0; i < str.length(); i++){
c = stb.charAt(i);
if( (c >= 65 && c <= 90) || (c >= 97 && c <= 122) ){
b++;
continue;
}
else if((b >= 1) && (i > 0 || c <= 64 || (c >= 91 && c <= 96) || c >= 123)){
b = 0;
a++;
}
}
if( b >= 1 ){
a++;
}
System.out.println(a);
}
}
}