Java查找统计文中字母,单词
package io;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException; public class First { public static void main(String[] args) throws IOException {
int a=0;int b=0;int c=0;int d=0;int e=0;int f=0;int g=0;int h=0;int i=0;int j=0;int k=0;int l=0;int m=0;int n=0;int o=0;int p=0;int q=0;
int r=0;int s=0;int t=0;int u=0;int v=0;int w=0;int x=0;int y=0;int z=0;
int A=0;int B=0;int C=0;int D=0;int E=0;int F=0;int G=0;int H=0;int I=0;int J=0;int K=0;int L=0;int M=0;int N=0;int O=0;int P=0;int Q=0;
int R=0;int S=0;int T=0;int U=0;int V=0;int W=0;int X=0;int Y=0;int Z=0;
// 新文件
File newFile = new File("d:\\File.txt");
char[] data=new char[1000];
// 读取文件内容
File file = new File("d:\\file.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuffer sb = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
System.out.println(line);
}
reader.close();
// 统计字母个数 for (int ii = 0; ii < sb.length(); ii++) {
char ch = sb.charAt(ii);
for(int qq=0;qq<1000;qq++) {
data[qq]=ch;
}
for(int qq=0;qq<1000;qq++) {
System.out.print(data[qq]);
}
if(ch=='A') {
A++;
}
if(ch=='B') {
B++;
}
if(ch=='C') {
C++;
}
if(ch=='D') {
D++;
}
if(ch=='E') {
E++;
}
if(ch=='F') {
F++;
}
if(ch=='G') {
G++;
}
if(ch=='H') {
H++;
}
if(ch=='I') {
I++;
}
if(ch=='J') {
J++;
}
if(ch=='K') {
K++;
}
if(ch=='L') {
L++;
}
if(ch=='M') {
M++;
}
if(ch=='N') {
N++;
}
if(ch=='O') {
O++;
}
if(ch=='P') {
P++;
}
if(ch=='Q') {
Q++;
}
if(ch=='R') {
R++;
}
if(ch=='S') {
S++;
}
if(ch=='T') {
T++;
}
if(ch=='U') {
U++;
}
if(ch=='V') {
V++;
}
if(ch=='W') {
W++;
}
if (ch=='X') {
X++;
} if (ch=='Y') {
Y++;
}
if (ch=='Z') {
Z++;
}
if (ch=='a') {
a++;
}
if (ch=='b') {
b++;
}
if (ch=='c') {
c++;
} if (ch=='d') {
d++;
}
if (ch=='e') {
e++;
}
if (ch=='f') {
f++;
}
if (ch=='g') {
g++;
}
if (ch=='h') {
h++;
}
if (ch=='i') {
i++;
}
if (ch=='j') {
j++;
}
if (ch=='k') {
k++;
}
if (ch=='l') {
l++;
}
if (ch=='m') {
m++;
}
if (ch=='n') {
n++;
}
if (ch=='o') {
o++;
}
if (ch=='p') {
p++;
}
if (ch=='q') {
q++;
}
if (ch=='r') {
r++;
}
if (ch=='s') {
s++;
}
if (ch=='t') {
t++;
}
if (ch=='u') {
u++;
}
if (ch=='v') {
v++;
}
if (ch=='w') {
w++;
}
if (ch=='x') {
x++;
}
if (ch=='y') {
y++;
}
if (ch=='z') {
z++;
}
}
System.out.println("a:"+a+"\t"+"b:"+b+"\t"+"c:"+c+"\t"+"d"+d);
System.out.println("e:"+e+"\t"+"f:"+f+"\t"+"g:"+g+"\t"+"h"+h);
System.out.println("i:"+i+"\t"+"j:"+j+"\t"+"k:"+k+"\t"+"l"+l);
System.out.println("m:"+m+"\t"+"n:"+n+"\t"+"o:"+o+"\t"+"p"+p);
System.out.println("q:"+q+"\t"+"r:"+r+"\t"+"s:"+s+"\t"+"t"+t);
System.out.println("u:"+u+"\t"+"v:"+v+"\t"+"w:"+w+"\t"+"x"+x);
System.out.println("y:"+y+"\t"+"z:"+z+"\t");
System.out.println("A:"+A+"\t"+"B:"+B+"\t"+"C:"+C+"\t"+"D"+D);
System.out.println("E:"+E+"\t"+"F:"+F+"\t"+"G:"+G+"\t"+"H"+H);
System.out.println("I:"+I+"\t"+"J:"+J+"\t"+"K:"+K+"\t"+"L"+L);
System.out.println("M:"+M+"\t"+"N:"+N+"\t"+"O:"+O+"\t"+"P"+P);
System.out.println("Q:"+Q+"\t"+"R:"+R+"\t"+"S:"+S+"\t"+"T"+T);
System.out.println("U:"+U+"\t"+"V:"+V+"\t"+"W:"+W+"\t"+"X"+X);
System.out.println("Y:"+Y+"\t"+"Z:"+Z);
}
}
Java查找统计文中字母,单词的更多相关文章
- JAVA实验--统计文章中单词的个数并排序
分析: 1)要统计单词的个数,就自己的对文章中单词出现的判断的理解来说是:当出现一个非字母的字符的时候,对前面的一部分字符串归结为单词 2)对于最后要判断字母出现的个数这个问题,我认为应该是要用到ma ...
- java统计英文字母、空格、数字和其它字符的数目
package tes; import java.util.Scanner; //java统计英文字母,空格,数字和其它字符的数目 public class ZiFuTongJi { public s ...
- java统计文本中单词出现的个数
package com.java_Test; import java.io.File; import java.util.HashMap; import java.util.Iterator; imp ...
- LeetCode 5216. 统计元音字母序列的数目(Java)DP
5216. 统计元音字母序列的数目 给你一个整数 n,请你帮忙统计一下我们可以按下述规则形成多少个长度为 n 的字符串: 字符串中的每个字符都应当是小写元音字母('a', 'e', 'i', 'o', ...
- PHP统计字符串里单词查询关键字
<?function full_count_words($str) { //返回完整数组,包含字符串里每个单词 $words = str_word_count($str,1); ...
- java string,需要进行首字母大写改写
java string,需要进行首字母大写改写,网上大家的思路基本一致,就是将首字母截取,转化成大写然后再串上后面的,类似如下代码 //首字母大写 public static String c ...
- c程序设计语言_习题1-13_统计输入中单词的长度,并且根据不同长度出现的次数绘制相应的直方图
Write a program to print a histogram of the lengths of words in its input. It is easy to draw the hi ...
- C语言习题1.分别统计一下其中字母,数字,其他字符的个数。将统计的字母,数字,其他字符的个数以柱状图的形式打印
从键盘上输入字符,(1)分别统计一下其中字母,数字,其他字符的个数, (2)将统计的字母,数字,其他字符的个数以柱状图的形式打印.例如 5 ***** ***** 3 ***** **** ...
- Java中过滤出字母、数字和中文的正则表达式
1.Java中过滤出字母.数字和中文的正则表达式 (1)过滤出字母的正则表达式 [^(A-Za-z)] (2)过滤出数字的正则表达式 [^(0-9)] (3)过滤出中文的正则表达式 [^(\\u4e0 ...
随机推荐
- PicGo+GitHub:你的最佳免费图床选择!
# PicGo介绍 这是一款图片上传的工具,目前支持SM.MS图床,微博图床,七牛图床,腾讯云COS,阿里云OSS,Imgur,又拍云,GitHub等图床,未来将支持更多图床. 所以解决问题的思路就是 ...
- python 36 进程池、线程池
目录 1. 死锁与递归锁 2. 信号量Semaphor 3. GIL全局解释器锁:(Cpython) 4. IO.计算密集型对比 4.1 计算密集型: 4.2 IO密集型 5. GIL与Lock锁的区 ...
- (一)配置linux环境实现持续集成
目录 1.Centos7操作系统 2.Gnome 可视化桌面 3.远程shell工具 4.远程桌面工具 5.Jdk 6..Net Core 7.Git 8.Docker 容器 9.Kubernetes ...
- Jedis操作Redis--String类型
/** * String(字符串) * APPEND,BITCOUNT,BITOP,BITFIELD,DECR,DECRBY,GET,GETBIT,GETRANGE,GETSET,INCR,INCRB ...
- HDU - 5128The E-pang Palace+暴力枚举,计算几何
第一次写计算几何,ac,感动. 不过感觉自己的代码还可以美化一下. 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5128 题意: 在一个坐标系中,有n个 ...
- CodeForces 103D Time to Raid Cowavans 询问分块
Time to Raid Cowavans 题意: 询问 下标满足 a + b * k 的和是多少. 题解: 将询问分块. 将b >= blo直接算出答案. 否则存下来. 存下来之后,对于每个b ...
- Codeforces Round #481 (Div. 3) C. Letters
题目地址:http://codeforces.com/contest/978/problem/C 题解:有n个宿舍,每个宿舍人不一样多,有m封信,每封信送给对应的第m间房间,问这封信是给第几个宿舍,第 ...
- Spring boot 全局配置 properties或者yml文件报错
主要问题是没有扫描到配置文件 在pom文件里面<build> </build>中加上以下代码就可以保证能扫描到了 <resources> <resour ...
- JavaScript new的运行过程
参考 MDN网站的运算符 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/new new 运算符 ...
- LeetCode - 字符串数字相乘与相加
43. 字符串相乘 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式. 示例 1: 输入: num1 = "2& ...