array

Array和ArrayList的区别

♀尐吖头ヾ 提交于 2020-01-12 23:55:33
Array是数组,可以存储基本类型和对象,ArrayList是集合,只能存储对象. Array初始化是指定大小的,ArrayList初始化大小是固定的. 来源: CSDN 作者: 乐于求知 链接: https://blog.csdn.net/nlv123/article/details/103949182

数组名作为函数参数一直错误提示,怎么才能用数组名作为函数参数

梦想与她 提交于 2020-01-12 19:36:54
数组名作为函数参数一直错误提示,怎么才能用数组名作为函数参数 void evaluate(int Arrayname[50]); void display(int Arrayname[50]); int main() { int array[20]; ; evaluate(array[20]); display(array[20]); } void display(int Arrayname[50]) { int i; for ( i = 0; i < 50; i++) { printf(“The member number is %d\n”, Arrayname[i]); } } void evaluate(int Arrayname[50]) { int i; for ( i = 0; i < 50; i++) { Arrayname[i]= i; } } 来源: CSDN 作者: AIjingna 链接: https://blog.csdn.net/AIjingna/article/details/103945974

【cpp上】课后正误小题

社会主义新天地 提交于 2020-01-12 19:20:47
State whether each of the following is true or false . If false , explain why. Assume the state ment using std::cout; is used. a) Comments cause the computer to print the text after the // on the screen when the program is executed. b) The escape sequence \n, when output with cout and the stream insertion operator,causes the cursor to position to the beginning of the next line on the screen. c) All variables must be declared before they’re used. d) All variables must be given a type when they’re declared. e) C++ considers the variables number and NuMbEr to be identical. f) Declarations can

排序

不问归期 提交于 2020-01-12 13:45:39
总表 排序算法 平均复杂度 最优复杂度 最差情况的复杂度 稳定性 空间复杂 起泡排序 n2 n n2 稳定 1 插入排序 n2 n n2 稳定 插入排序 选择排序 n2 n2 n2 不稳定 1 希尔排序 n2 不稳定 1 快速排序 nlogn nlogn n2 不稳定 logn 堆排序 nlogn nlogn nlogn 不稳定 1 归并排序 nlogn nlogn nlogn 稳定 n 插入排序: 把整个序列分为有序的前半部分和无序的后半部分,每次从无序的后半部分取出第一个插入到有序部分中间 起泡排序: 每次比较相邻的两个元素,若前者较大则交换两个元素的顺序,每轮会把一个最大元素交换到最后的位置; 选择排序: 把整个序列分为有序的前半部分和无序的后半部分,每次从无序的后半部分选取最小元素插入到有序部分的末尾 快速排序: 每次以某个元素为界(一般是第一个元素)将整个序列按大小划分为两部分,然后递归地对左右两组元素做同样的事情 void quickSort ( int [ ] array , int start , int end ) { if ( start >= end ) { return ; } boolean order = true ; int i = start ; int j = end ; while ( i != j ) { if ( array [ i ] >

js经典算法

偶尔善良 提交于 2020-01-12 08:40:01
1:检测100以内的素数 function sushu ( num ) { for ( var i = 2 ; i <= num ; i ++ ) { //当前的数,是不是素数 var isactive = false ; for ( var k = 2 ; k < i ; k ++ ) { if ( i % k == 0 ) { isactive = true ; } } if ( ! isactive ) { console . log ( i ) ; } } } sushu ( 100 ) ; 2:将1000000.11转换为rmb的形式 var n = 1000000.11 ; function rmb ( price ) { //考虑小数点之前的都能拿到 price = price . toString ( ) ; var xiaoshu = price . split ( "." ) [ 1 ] ; if ( xiaoshu == undefined ) { xiaoshu = "" ; } else { xiaoshu = "." + xiaoshu ; } var intnum = price . split ( "." ) [ 0 ] . split ( "" ) . reverse ( ) . join ( "" ) ; console . log (

Leetcode: Create Maximum Number

耗尽温柔 提交于 2020-01-12 07:45:12
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k digits. You should try to optimize your time and space complexity. Example 1: nums1 = [3, 4, 6, 5] nums2 = [9, 1, 2, 5, 8, 3] k = 5 return [9, 8, 6, 5, 3] Example 2: nums1 = [6, 7] nums2 = [6, 0, 4] k = 5 return [6, 7, 6, 0, 4] Example 3: nums1 = [3, 9] nums2 = [8, 9] k = 3 return [9, 8, 9] We can use greedy method to solve this. num1 can take charge of

javascript 详解数组

跟風遠走 提交于 2020-01-12 07:18:03
概念 数组创建 数组读写 数组 VS. 一般对象 相同点 不同点 稀疏数组 数组的length属性 元素增删 数组迭代 二维数组 数组方法 Array.prototype.join Array.prototype.reverse Array.prototype.sort Array.prototype.concat Array.prototype.slice 切片 Array.prototype.splice 胶接 Array.prototype.forEach (ES5) Array.prototype.map (ES5) Array.prototype.filter (ES5) Array.prototype.every (ES5) Array.prototype.some (ES5) Array.prototype.reduce/reduceRight (ES5) Array.prototype.indexOf/lastIndexOf (ES5) Array.isArray (ES5) 字符串和数组 最近在学习数组,发现很多ES5的方法平时很少用到。细节比较多,自己做了大量例子和整理,希望对大家了解JavaScript中的Array有所帮助。 概念 数组是值的有序集合。每个值叫做元素,每个元素在数组中都有数字位置编号,也就是索引。JS中的数组是弱类型的

[LC] 384. Shuffle an Array

纵饮孤独 提交于 2020-01-12 04:48:42
Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums); // Shuffle the array [1,2,3] and return its result. Any permutation of [1,2,3] must equally likely to be returned. solution.shuffle(); // Resets the array back to its original configuration [1,2,3]. solution.reset(); // Returns the random shuffling of array [1,2,3]. solution.shuffle(); class Solution { private int[] arr; private Random rand; public Solution(int[] nums) { this.arr = nums; rand = new Random(); } /** Resets the array to its

JS数组学习笔记

依然范特西╮ 提交于 2020-01-11 23:26:34
原文: JS数组学习笔记 最近在备课数组,发现很多ES5的方法平时很少用到。细节比较多,自己做了大量例子和整理,希望对大家了解JavaScript中的Array有所帮助。 概念 数组是值的有序集合。每个值叫做元素,每个元素在数组中都有数字位置编号,也就是索引。JS中的数组是弱类型的,数组中可以含有不同类型的元素。数组元素甚至可以是对象或其它数组。 JS引擎一般会优化数组,按索引访问数组常常比访问一般对象属性明显迅速。 数组长度范围 from 0 to 4,294,967,295(2^23 - 1) 数组创建 var BAT = ['Alibaba', 'Tencent', 'Baidu']; var students = [{name : 'Bosn', age : 27}, {name : 'Nunnly', age : 3}]; var arr = ['Nunnly', 'is', 'big', 'keng', 'B', 123, true, null]; var arrInArr = [[1, 2], [3, 4, 5]]; var commasArr1 = [1, , 2]; // 1, undefined, 2 var commasArr2 = [,,]; // undefined * 2 var arr = new Array(); var arrWithLength

PHP中的list()说明

青春壹個敷衍的年華 提交于 2020-01-11 17:35:13
list() 用于在一次操作中给一组变量赋值。 注释:list()只用于数字索引的数组,且假定数字索引从 0 开始。 说明 list() 用数组中的元素为一组变量赋值。 注意,与 array() 类似,list() 实际上是一种语言结构,不是函数。 如: <?php   $my_array = array('Dog','Cat','Horse');   list($a, $b, $c) = $my_array;   echo 'I have several animals, a '.$a.', a '.$b.' and a '.$c; ?> 结果如下,可正常输出 当数组不是数字数组而是关联数组时,如: <?php $my_array = array('a'=>'Dog','b'=>'Cat','c'=>'Horse'); list($a, $b, $c) = $my_array; echo 'I have several animals, a '.$a.', a '.$b.' and a '.$c; ?> 结果将会报错 当使用索引数组是如: <?php   $my_array = array(0=>'Dog',1=>'Cat',2=>'Horse');   list($a, $b, $c) = $my_array;   echo 'I have several animals, a