count_char
import java.util.Scanner;
public class count_char
{
public static void main(String args[])
{
int count1=0,count2=0,count3=0,count4=0;
String str;
Scanner reader = new Scanner(System.in);
while((str=reader.nextLine())!=null)
{
char temp[]=str.toCharArray();
for(int i=0; i<temp.length; i++)
{
if(Character.isLetter(temp[i])) count1++;
else if (Character.isDigit(temp[i])) count2++;
else if (Character.isWhitespace(temp[i])) count3++;
else count4++;
}
System.out.printf("letter:%d number:%d Whitespace:%d another:%d \n"
, count1, count2, count3, count4);
str="";
}
}
}
count_char的更多相关文章
- 【转】shell脚本处理字符串的常用方法
转自:http://blog.csdn.net/linfeng999/article/details/6661233 1. 构造字符串 直接构造 STR_ZERO=hello #shell中等号左右的 ...
- Shell中的正则表达式及字符串处理
shell里一个正则表达式就是由普通字符(例如字符 a 到 z)以及特殊字符(称为元字符)组成的文字模式.该模式描述在查找文字主体时待匹配的一个或多个字符串.正则表达式作为一个模板,将某个字符模式与所 ...
- Python学习入门基础教程(learning Python)--6.4 Python的list与函数
list是python下的一种数据类型,他和其他类型如整形.浮点型.字符串等数据类型一样也可作为函数的型参和实参来使用! 1.list作为参数 list数据类型可以作为函数的参数传递给函数取做相应的处 ...
- 【转】shell字符串截取
shell字符串的截取的问题: 一.Linux shell 截取字符变量的前8位,有方法如下: 1.expr substr “$a” 1 8 2.echo $a|awk ‘{print substr( ...
- 震惊!!!源程序特征统计程序——基于python getopt库
项目github地址:https://github.com/holidaysss/WC PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟 ...
- Implementation of WC in JAVA
Implementation of WC in JAVA github地址 相关要求 基本功能 -c [文件名] 返回文件的字符数 (实现) -w [文件名] 返回文件的词的数目 (实现) -l [文 ...
- poj1521
霍夫曼编码,建树 #include <cstdio> #include <cstring> #include <queue> using namespace std ...
- Python学习手册之数据类型
在上一篇文章中,我们介绍了 Python 的异常和文件,现在我们介绍 Python 中的数据类型. 查看上一篇文章请点击:https://www.cnblogs.com/dustman/p/99799 ...
- 常用shell脚本命令
常用shell脚本命令 1.显示包含文字aaa的下一行的内容: sed -n '/aaa/{n;p;}' filename 2.删除当前行与下一行的内容: sed -i '/aaa/{N;d;}' f ...
随机推荐
- SQL Server ->> 生成时间类型的Partition Function和Partition Scheme代码
有时工作中要建个分区函数,可是像日期这种分区函数要是搞个几百个的值那不是要搞死我.于是写了点代码自动生成一个从1990年开始的按月的分区函数和对应的分区主题 USE [TestDB] GO DECLA ...
- (四)WebDriver常用方法
点击和输入 前面我们已经学习了定位元素, 定位只是第一步, 定位之后需要对这个元素进行操作, 或单击(按钮) 或输入(输入框) , 下面就来认识 WebDriver 中最常用的几个方法: clear( ...
- github 专案介绍 – Python 范例:透过互动式的 Jupyter 和数学解释流行的机器学习演算法
对于机器学习有兴趣,不少人应该会先从 Andrew Ng ( 吴恩达 ) 的机器学习课程开始,但是吴恩达的课程是使用 octave 这个工具当作练习.这个 github 项目包含使用 Python 实 ...
- static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16
查看HashMap源码,发现这个static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; 值为16. 这个是位移算法. 例如: 4<& ...
- python26 re正则表达式
#coding:utf-8 #/usr/bin/python """ 2018-11-25 dinghanhua re """ import ...
- 【转载】#438 - Benefits of Using Interfaces
You might wonder why you'd define an interface, have a class implement that interface and then acces ...
- postgres循环sql
CREATE OR replace function loop_addDevice(i integer) RETURNS integer as $$ declare count alias ; all ...
- Django:web框架本质
一,web框架本质 我们可以这样理解:所有的Web应用本质上就是一个socket服务端,而用户的浏览器就是一个socket客户端. 这样我们就可以自己实现Web框架了. 1,自定义web框架 impo ...
- GoBelieve Android SDK接入备忘
Android SDK版本 目前SDK只支持Android 2.2或以上版本的手机系统. AndroidManifest.xml配置 以下配置可以在IMDemo/AndroidManifest.xml ...
- SpringBoot非官方教程 | 第七篇:springboot开启声明式事务
转载请标明出处: http://blog.csdn.net/forezp/article/details/70833629 本文出自方志朋的博客 springboot开启事务很简单,只需要一个注解@T ...