首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
1576684866
2024年3月21日 20:51
字母频率 题解:
P1019
回复 0
|
赞 0
|
浏览 792
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> using namespace std; #include <string.h> #include <algorithm> #include <iostream> #include <map> #include <stdlib.h> int main() { char s[1005]; gets(s); &nb...
小酒
2024年3月16日 18:41
字母频率 题解:
P1019
回复 0
|
赞 3
|
浏览 749
1019解题思路:同样,用数组来记录 #include <bits/stdc++.h> using namespace std; int main() { char a[1000]={0}; gets(a); int l=strlen(a); int b[105]={0}; for(int i=0;i<l;i++) { if(a[i]>='A'&&a[i]<='Z') { int k=0; k=a[i]%65; b[k]++; } if(a[i]>=...
FIVEszc
2024年3月13日 20:51
字母频率 题解:C++
P1019
回复 0
|
赞 1
|
浏览 1.4k
#include <bits/stdc++.h> using namespace std; typedef struct table{ char a; int count; }; char s[1000]; int main() { table alphabet [26]; for(int i=0;i<26;i++) { al...
Cookie‘s AE86
2024年3月13日 10:47
字母频率 题解:c++ vector、set、count实现
P1019
回复 0
|
赞 0
|
浏览 857
#include<bits/stdc++.h> using namespace std; int main(){ string s; getline(cin, s); vector<char> vs; set<char>ss; //将字符串转换成小写 transform(s.begin(), s.end(), s.begin(), ::tolower); //分别将字符串存入动态数组和集合中 for(int i = 0; i < s.size(); i++...
xhpn
2024年3月5日 21:23
字母频率 题解:数组模拟哈希表
P1019
回复 0
|
赞 0
|
浏览 847
#include<stdio.h> #include<string.h> int main(){ int count[26]={0}; int i; char s[1000]; gets(s); int len=strlen(s); for(i=0;i<len;i++){ ...
zx142407789
2024年3月5日 14:27
字母频率 题解:自用笔记
P1019
回复 0
|
赞 0
|
浏览 975
初始化一个字母表并且将频数设为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.2k
#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.2k
#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.5k
#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.0k
注意:最多的字符可能不止一个 #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...
1
2
3
题目
字母频率
题解数量
27
发布题解
在线答疑
热门题解
1
字母频率 题解:纯数组 C语言写法 很好理解
2
字母频率 题解:
3
字母频率 (C++11 哈希表)题解:
4
使用哈希,感觉应该最简单了
5
字母频率 题解:自用
6
字母频率 题解:C
7
字母频率 题解:cpp 哈希表 所有字符统计频率
8
字母频率 题解:
9
题解:字母频率
10
字母频率(感觉要用链表,但是不会啊,所以就用for做了)