首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
zx142407789
2024年3月5日 14:27
字母频率 题解:自用笔记
P1019
回复 0
|
赞 0
|
浏览 1.3k
初始化一个字母表并且将频数设为0,通过输入对单个字符逐一记录,考虑到有多个字母有相同频数且是出现次数最多的 #include<stdio.h> typedef struct { char x; int count; }Alphabet; int main() { Alphabet tab[26]; Alphabet max; char ch; int k = 0; for (int i = 0; i < 26; i++) {//初始化字母表 tab[i].x = 'a' + i; tab[i].count = 0;...
Hegel
2023年3月21日 10:10
字符频率
P1019
回复 0
|
赞 1
|
浏览 3.6k
#include <iostream> #include <string> using namespace std; int main() { string s; while (getline(cin, s)) { int a[26] = { 0 }, max = 0; for (int i = 0; i < s.size(); i++) { if (s[i] >= 'a' && s[i] <= 'z') a[s[i] - 'a']++; if (s[i] >= 'A'...
huangdashuaige
2023年2月15日 23:49
P1019题解
P1019
回复 0
|
赞 2
|
浏览 4.5k
#include <iostream> using namespace std; int main(){ /*思路:用一个字符串记字符,一个数组次序代替26个字母(也可以使用map<char,int>或vector) 输入字母时,直接进行判断次数,输出*/ int zms[26],s; //zms是记录字母出现频次用的,s是中间值 char c[1000]; &...
xpc
2020年4月7日 18:12
直接构造一个辅助数组即可
P1019
回复 0
|
赞 0
|
浏览 11.8k
#include<iostream> using namespace std; int arr[128]={0}; int main(){ string s; getline(cin,s); for(int i=0;i<s.size();++i){ ++arr[s[i]-'\0']; } int maxi=0,maxnum=0; &nbs...
A1120161820
2020年3月21日 09:41
字母频率(c++)
P1019
回复 0
|
赞 0
|
浏览 12.3k
注意:最多的字符可能不止一个 #include<iostream> #include<cstring> using namespace std; const int M = 1024; int main() { char line[M]; cin.getline(line, M); int a[30];//将字母映射到0-25,从而保存出现的次数 memset(a, 0, sizeof(a));//初始化 int i = 0; while (line[i]) { if (line[i] >= 'a' &a...
mzymzyo
2020年2月22日 22:17
题解:字母频率
P1019
回复 0
|
赞 2
|
浏览 10.8k
读取整行用的getline,获得最大值用的“打擂台法” #include<string>//getline #include<iostream> using namespace std; int a[26]; int main() { string s, s1; getline(cin, s); for (int i = 0; i < s.length(); i++) { if ('A' <= s[i] && s[i] <= 'Z') a[s...
创世的背影
2019年12月10日 17:24
字母频率(感觉要用链表,但是不会啊,所以就用for做了)
P1019
回复 0
|
赞 2
|
浏览 10.9k
#include<stdio.h> #include<string.h> #include<math.h> int main() { int i,j,k,l,b[26],x; char a[999],c[26],y; gets(a); j=strlen(a); a[j]='\0'; k=0; c[0]='a'...
wudiyiyi
2020年4月3日 09:17
用STL中的map和string非常方便,只需要先把字符转换成小写就o
P1019
回复 0
|
赞 1
|
浏览 9.6k
#include <bits/stdc++.h> using namespace std; map<char,int>mp; string s; int main() { getline(cin,s); for(int i=0;i<s.size();i++) { if(s[i]>='A'&&s[i]<='Z') s[i]=tolower(s[i...
谦虚使人进步
2020年1月16日 09:27
这是我第一遍想到的结果,还没想有没有更好的,写完全部有时间再做一遍
P1019
回复 0
|
赞 0
|
浏览 10.7k
//这种题我一般是用数组做,其中127位是因为 ASCII码最后一位是 0111 1111 0177 127 0x7F DEL (delete) 删除 //十进制是127 #include <iostream> #include <string> using namespace std; int main(void...
1435647858
2020年3月13日 23:53
第一想法就是用string做,请各位多指教
P1019
回复 0
|
赞 2
|
浏览 9.0k
#include<bits/stdc++.h> using namespace std; int main(){ string s,t; getline(cin,s); int pos=0; int a[26]={0}; transform(s.begin(),s.end(),s.begin(),::tolower); t=s; &n...
1
2
3
4
题目
字母频率
题解数量
32
发布题解
在线答疑
热门题解
1
字母频率 题解:纯数组 C语言写法 很好理解
2
字母频率 题解:
3
字母频率 (C++11 哈希表)题解:
4
字母频率 题解:自用
5
使用哈希,感觉应该最简单了
6
字母频率 题解:cpp 哈希表 所有字符统计频率
7
字母频率 题解:C
8
字母频率 题解:
9
字母频率 题解:
10
题解:字母频率