鱼C论坛

 找回密码
 立即注册
分享 使用 join 方法将存储组合成字符串
hayeee 2025-1-6 03:55
该 join 方法用于将数组的元素连接在一起以创建字符串。它接受一个参数作为分隔符,用于分隔字符串中的数组元素。 请看下面的例子: const arr = ; const str = arr . join ( " " ) ; str 想要翻译的句子 Hello World 。 在函数 sentensify 内用 join 方法(及其他方法)用字符串 str 中 ...
0 个评论
分享 使用 split 方法将字符串拆分成数组
hayeee 2025-1-6 03:50
该 split 方法将字符串拆分为字符串数组。它接受分隔符参数,分隔符可以是用于拆分字符串的字符或正则表达式。例如,如果分隔符是空格,则将获得单词数组;如果分隔符是空字符串,则将获得字符串中每个字符的数组。 下面是用两个空格分隔一个字符串的例子,另一个是用数字的正则表达式分隔: const str = "Hell ...
0 个评论
分享 在不更改原始数组的前提下返回排序后的数组
hayeee 2025-1-3 04:05
A side effect of thesortmethod is that it changes the order of the elements in the original array. In other words, it mutates the array in place. One way to avoid this is to first concatenate an empty array to the one being sorted (remember thatsliceandconcatret ...
0 个评论
分享 使用排序方法按字母顺序给队列排序
hayeee 2025-1-3 03:51
该 sort 方法根据回调函数对数组元素进行排序。 举个例子: function ascendingOrder ( arr ) { return arr . sort ( function ( a , b ) { return a - b ; } ) ; } ascendingOrder ( ) ; 命运返回值 。 function reverseAlpha ( arr ) { ...
0 个评论
分享 构造结构体来存放每个学生的数据,并计算
Maliaty 2024-12-25 16:54
#include stdio.h #include string.h #define N3 struct STUDENT { long int num ; char name ; int age ; float eng ...
1 次阅读|1 个评论
分享 12.24
zyx2012 2024-12-24 06:05
距离期末还有最后10天
0 个评论
分享 使用高阶函数map、filter或者reduce来解决复杂问题
hayeee 2024-12-23 12:24
map() 现在您已经使用、 filter() 和 等高阶函数解决了一些挑战 reduce() ,现在您可以应用它们来解决更复杂的挑战。 使用 map() 、 filter() 和 reduce() 任何组合完成 squareList 函数的代码。 提交一个包含实数的数组给函数时,函数应返回一个新的数组, 只 包含正整数(小数不是整数)的平方值,例如 这 ...
0 个评论
分享 替换字符串;临时数组的灵活运用
Maliaty 2024-12-19 19:40
#include stdio.h #include string.h void replace ( char * str , char * fstr , char * rstr ); void replace ( char * str , char * fstr , char * rstr ) { int len0 = strlen ( str ); int len1 = strlen ( fstr );   ...
1 次阅读|1 个评论
分享 分函数使用局部静态变量,并传出该地址,主函数中如何调用该静态变量
Maliaty 2024-12-19 17:17
#include stdio.h #include string.h int * count ( char * ch_p ); int * count ( char * ch_p ) { int len = strlen ( ch_p ); static int vowel = 0 ; vowel = 0 ; // 重置元音计数器 for ( int ...
0 个评论
分享 思考最后的子字符串是否有可能是最长
Maliaty 2024-12-17 17:46
#include stdio.h #include string.h // 函数 search:找到并返回最长由同一字符组成的子字符串的长度 int search(char *cpSource, char ch) { int maxLen = 0; // 最大长度 int currentLen = 0; // 当前长度 int len = strlen(cpSource); &nb ...
0 个评论

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-12 20:19

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

返回顶部