字母统计次数 软件 java统计字母出现次数
发布日期:2021-04-19摘要:有没有能统计一篇英文文章中所有单词出现次数的软件比如,我手里 推荐用Replace Pioneer的Pattern Counter 来统计,统计出来的结果用鼠标全部选中,然后按ctrl-c就可以拷...
有没有能统计一篇英文文章中所有单词出现次数的软件比如,我手里...
推荐用Replace Pioneer的Pattern Counter 来统计,统计出来的结果用鼠标全部选中,然后按ctrl-c就可以拷贝到剪贴板里.详细步骤:首先需要把该英文文章保存为txt文本文件,然后:1. 安装并打开Replace Pioneer, 选择Tools->Pattern Counter菜单2. 在上面的Source选择 File/http,然后在右边输入(或选择)txt文本的路径.3. 确定Counter Template选择的是Characters, Words, Lines(默认值)4. 点中第3行Words,然后点击Detail,就可以按照出现次数列出所有词的频率.不仅如此,你可以统计任何模式的出现频率,比如标点符号,单个字符,双字符组合,等等.如果你会正则表达式,你甚至可以统计有多少个词是以s结尾的,多少个词是3个字母的,等等任意统计.如果你想同时统计多个文件,可以把多个文件先合并再统计,具体可以参看以下英文版内容:How to count and sort the frequency of all words appeared in many text files?
C语言编程:输入一串字母,统计每个字母出现的次数
/遇到大写字母时,转换成小写来处理 ch+=32; s[ch-"a"]++; //ch用来每次接收一个字符 int i;a"please input a string;Z"26;i++) if(s[i]) / } printf(""A"&&ch(char)(i+" //n"; //)#include) /数组s[]用来统计每个小写字母的个数 printf("\n"/只输出输入过的字母统计 printf(" scanf("%c";void main(){ char ch; /a"%c:%d\) //,(char)(i+",&ch),&ch); while(ch!="\...
编写一个C语言程序:从键盘读入一行文本,统计每个英文字母出现的...
z"A" i++) { / 26;stdlib.h> i++) { //#define MAX 100int main(){ char str[MAX].h>#include = ") { //, i + 65;, str); while(str[i] != "a"\0") { if (str[i] >= " 只输出不为零的数据 } for (i = 26; i < count 数组用来存储各个字母出现的次数 scanf(" 输入的字符串,最大长度是MAX-1,因为有一个字符串结束符 int i = 0; //stdio;/ 输出大写字母信息 if (count[i] ;, i + 97 - 26;n", count[i]); //!= 0) printf("%c\ && str[i] <= "%s"%c\t%d\n" } i++; } for (i = 0; i < 输出小写字母信息 if (count[i] != 0) printf("t%d\ && str[i] <= "#include <
字母频率统计-C语言
如果使用Java中的一些结合==集合类会简便一些,但我这里还是硬来,实例:输入jacka输出:k:0.2c:0.2j:0.2a:0.4觉得我做的辛苦的话,多加点分吧代码:import java.util.*;public class CharNumber {public void test(){Scanner scan=new Scanner(System.in);System.out.println("input the string:");String s=scan.nextLine();char[] ch=s.toCharArray();double[] percent=new double[ch.length];//存放比例char[] resultch=new char[ch.length];int[] resultnum=new int[ch.length];int index=0;for(int i=0;i{if(i==0) {resultch[index]=ch[i];resultnum[index]++;}else {int j;for(j=0;j{if(ch[i]!=resultch[j]) {continue;}else {resultnum[j]++;break;}}if(j>index) {index++;resultch[index]=ch[i];resultnum[index]++;}}}for(int x=0;x{percent[x]=Math.round(((double)resultnum[x]/ch.length)*100)/100.0;}//排序,插入排序for(int ii=1;ii{int pos=ii;int prepos=pos-1;double temp=percent[pos];double pre=percent[prepos];char tempch=resultch[pos];while(prepos>=0){if(temp{percent[prepos+1]=percent[prepos];resultch[prepos+1]=resultch[prepos];prepos--;}else {percent[prepos+1]=temp;resultch[prepos+1]=tempch;break;}}if(prepospercent[prepos+1]=temp;resultch[prepos+1]=tempch;}}//输出for(int i=0;i{System.out.println(resultch[i]+":"+percent[i]);}}}
编写程序,从键盘输入若干个英文字母,并统计个字母出现的次数(不...
#include void main(){char str[1000];scanf("%s",str);int iCount=0;for(int i=0;i=65&&str[i]<=90 || str[i]>=97&&str[i]<=122){iCount++;}}printf("%d",iCount);}
用java,统计txt文件中每个文字或者字母出现的次数,并由大到小排...
import java.io.*;import java.util.*;/**题目:用java,统计txt文件中每个文字或者字母出现的次数,并由大到小排列,并显示每个文字或者字母出现的次数思路:1.定义字符读取(缓冲)流2.循环读取文件里的字符,用一个String类型变量接收(newValue)3.把newValue变成字符数组 char[] ch = newValue.toCharArray();4.遍历ch 将ch中所有的字符存入一个Map集合中(TreeSet),键对应字符,值对应字符出现的次数5.遍历打印map集合中的键和值,也就是字符出现的次数**/public class T06 {public static void main(String[] args){demo(new File("d:\\io.txt"));}public static void demo(File file){BufferedReader bfr = null; //定义字符读取(缓冲)流try{bfr = new BufferedReader(new FileReader(file));//给该流赋值String value = null; //定义一个临时接收文件中的字符串变量String newValue = ""; //接收文件中所有字符串的变量while((value = bfr.readLine())!=null){ //开始读取文件中的字符newValue = newValue+value; //存入newValue变量中}char[] ch = newValue.toCharArray();//把newValue变成字符数组TreeMaptm = new TreeMap(Collections.reverseOrder());/*定义一个TreeMap(因为TreeMap是有序的,存入的键值都有自然比较顺序功能,默认的是从小到大顺序,所有这里传了一个反转的比较器),键对应字符,值对应字符出现的次数**/for(int x = 0;xchar c = ch[x];if(tm.containsKey(c)){ //如果TreeMap(tm)中有该键,则取出该键中的值,也就是出现的次数int conut = tm.get(c);tm.put(c,conut+1); //存入把新值存入tm集合中,如果键相同的话, 新键会替换老键,值也随着变化了}else{tm.put(c, 1); //如果没有出现该键就说明是第一次出现,然后就存入1次}}//下面的是取出TreeMap(tm)中的键和值Set>set = tm.entrySet();Iterator>iter = set.iterator();while(iter.hasNext()){Map.Entrymap = iter.next();char k = map.getKey();int v = map.getValue();System.out.print(k+"("+v+") ");}}catch(IOException e){System.out.println("文件读取错误");}finally{try{if(bfr!=null)bfr.close();}catch(IOException e){System.out.println("文件关闭错误");}}}}
用C语言编写一个程序,输入一个字符串,统计其中各个字符出现的次...
stdio;main(void){ char ch;="=",b;z".h>int )c++;else d++;}printf("字母=%d\n数字=%d\n空格=%d\n其他字符=%d\n",分别统计出其中字母;A"&&a"&&)b++;else if(ch==" "!="Z",c、空格、数字和其他字符的个数;&&ch="\n"){if(ch>9"="||ch>0"//输入一行字符...
java统计字母出现次数
public class CountLettersInArray {/**Main method*/public static void main(String args[]){//Declare and create an arraychar[] chars = createArray();//Display the arraySystem.out.println("The lowercase letters are:");displayArray(chars);//Count the occurrences of each letterint[] counts = countLetters(chars);//Display countsSystem.out.println();System.out.println("The occurrences of each letter are:");displayCounts(counts);}public static char[] createArray() {char[] chars = new char[100];for(int i = 0; i // chars[i] = RandomCharacter.getRandomLowerCaseLetter();chars[i]=(char)(((int)(Math.random()*26))+"a");return chars;}/**Create an array of characters*/public static void displayArray(char[] chars){//Display the characters in the array 20 on each linefor(int i = 0;i if((i + 1) % 20 == 0)System.out.println(chars[i]);elseSystem.out.print(chars[i] + " ");}}public static int[] countLetters(char[] chars){//Declare and create an array of 26 intint[] counts = new int[26];for(int i = 0;i counts[chars[i]-"a"]++;return counts;}public static void displayCounts(int[] counts){for(int i = 0;i if((i + 1) % 10 == 0)System.out.println(counts[i] + " " + (char)(i + "a"));elseSystem.out.print(counts[i] + " " + (char)(i + "a") + " ");}System.out.println();}}
c语言统计字母出现次数
看我旁边做的注解cnt(s,array); /*调用子函数cnt,并传给参数s, array。
s是字符数组,相当于字符串指针;array是数组好理解*/for(i=0;iprintf("%d",array[i]); /* for循环 依次输出26个字母出现的次数。
这里%d后面加个空格或逗号分隔才好 */printf("\n");子函数 void cnt(char *p,int arr[]) /* 第一个参数是字符串指针,第二个参数是整型数组 */{int i;for(i=0;iarr[i]=0; /* 26个字母的个数全初始设置为0 */while(*p) /* 循环,*p表示取指针p所指的字符,如果为0则表示字符串结束,退出循环 */{if(*p>="a"&&*parr[*p-"a"]++; /*p与字母a的差值刚好就是数组arr下标*/ /* 字母a对应数组的下标是0, b是1,依次类推 */p++; /* 指针加1, 指向后面一个字符 */}}
-
给我们打电话
7*24小时服务热线:1399999999
全国客服热线:400-0000-000 -
百度地图
福建省漳州市 -
给我们发邮件
E-mail:[email protected]
在线沟通