首页
DreamJudge
院校信息
考研初试
机试真题
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
damowanghwj
2024年3月6日 18:49
变位词 题解:map实现哈希表 有点麻烦
P1032
回复 0
|
赞 1
|
浏览 608
#include<cstdio> #include<iostream> #include<string> #include<map> using namespace std; map<char,int> myMap = { {'a',1}, {'b',2},{'c',3},{'d',4},{'e',5} ,{'f',6},{'g',7},{'h',8}...
小王桐学
2024年2月11日 21:26
变位词 题解:c-排序直接比较大小
P1032
回复 0
|
赞 16
|
浏览 1.0k
#include <stdio.h> #include <string.h> void Sort(char *s) { int i,j; char c; for(i = 0; i < strlen(s)-1; i++) for(j = 1; j < strlen(s)-i; j++) if(s[j] < s[j-1]) { c = s[j]; s[j] = s[j-1]; s[j-1] = c; } } int main() { char s1[1...
Hegel
2023年3月28日 21:12
输入字符串s1与s2,比较字符串s2是否为字符串s1变换而来
P1032
回复 0
|
赞 5
|
浏览 2.4k
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string s1,s2; cin >> s1 >> s2; int a[26] = { 0 }, b[26] = { 0 }; for (int i = 0; i < s1.size(); i++) a[s1[i] - 'a']...
Sonder
2022年2月27日 17:31
变位词-哈希表
P1032
回复 0
|
赞 1
|
浏览 5.4k
#include <iostream> #include <cstring> #include <algorithm> #include <unordered_map> using namespace std; int main() { int n; cin >> n; while (n -- ) { string a,b; ...
hijack
2020年7月19日 09:22
变位词(先排序再比较)
P1032
回复 0
|
赞 2
|
浏览 10.2k
#include <iostream> #include <cstring> using namespace std; void bubble(char s1[]); int main() { int n; cin >> n; char s1[100], s2[100]; while(n--) { cin >> s1 >> s2; int len1 = strlen(s1); int len2 = strlen(s2); int flag_bw = 0; //变为词标记,...
大白
2020年6月19日 09:40
Accepted答案-变位词(C)
P1032
回复 0
|
赞 2
|
浏览 10.3k
代码已通过,accepted 我的算法思想是利用两个特征数列(数组)去对比两个词是否是变位词。同时再用一个s数组去记忆每组结果。最后根据s数据集中判断Yes或者No。 处理部分有很多细节,我已经标有注释,所用语法没有超出课程内容。 代码如下: #include<stdio.h> int main(){ int n; int t1[26]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; int ...
ymw1836828452
2020年5月7日 10:27
题解
P1032
回复 0
|
赞 0
|
浏览 9.6k
#include <stdio.h> #include <stdlib.h> #include <string.h> void judge(char *p) { int t=0,j,i,k; j=strlen(p);//利用strlen函数 k=(j-1)/2; for(;*p!=' ';p++) { for(i=j-1;p[i]...
mzymzyo
2020年2月23日 19:17
题解:变位词
P1032
回复 0
|
赞 2
|
浏览 9.8k
先将两个字符串都按照ascii码大小进行排序,在比较排序后是否一样 排序用sort()函数,头文件<algorithm> #include<algorithm> #include<iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string s1, s2; cin >> s1 >> s2; sort(s1.begin(),...
A1120161820
2020年3月24日 11:21
变位词(c++)
P1032
回复 0
|
赞 1
|
浏览 13.5k
#include<iostream> #include<cstring> #include<cstdlib> using namespace std; int cmp(const void* a, const void* b) { return (*(char*)a - *(char*)b); } int main() { char s1[105], s2[105]; int n; cin >> n; while (n--) { memset(s1, 0, sizeof(s1)); mem...
1
2
题目
变位词
题解数量
19
发布题解
在线答疑
热门题解
1
变位词 题解:统计各字母数量
2
变位词 题解:c-排序直接比较大小
3
变位词 题解:先sort()排序再比较
4
变位词 题解:简单sort 然后strcmp就行了
5
变位词 题解qsort排序
6
变位词 题解:暴力
7
输入字符串s1与s2,比较字符串s2是否为字符串s1变换而来
8
变位词 (哈希表)题解:
9
变位词 题解:用map<char,int>
10
变位词 题解:直接删除 很爽的