📄 统计一串字符中空格的个数.txt
字号:
import java.io.*;
class CountSpace{
public static void main(String[] args)
throws IOException{
Reader in;
in=new InputStreamReader(System.in);
int ch;
int totol;
int spaces=0;
for(total=0;(ch=in.read())!=-1;total++)
{
if(Character.isWhitespace((char)ch))
spaces++;
}
System.out.println(total+ “个字符, ”+spaces+ “个空格”);
}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -