A topic
Provided the circular queue array subscript range is 1 ~ n, which is the head and tail pointers are f and r, it is the number of elements (D).
A.r-f B.r-f+1 C.(r-f) mod n +1 D.(r-f+n) mod n
Explanation:
Note that this problem is an index from the index so that the circular queue a start up with n elements
in the circular queue, a head pointer points to the first element among the queues, and the tail pointer to the next element in a last
Suppose the cycle end of the queue pointers are rear, is a head-front, which is the maximum length QueueSize circular queue.
(1) the tail pointer is incremented by 1 enqueued: (rear + 1)% QueueSize
(2) when the queue head pointer is dequeued forward 1: (front + 1)% QueueSize
(3) the queue length: (rear-front + QueueSize)% QueueSize
A conventional cyclic queue, which queue head pointer Front, the tail pointer is REAR; circular queue length is N. Its effective length of the squad? (Assuming that the first team does not store data)
Answer: (rear-front + N)% N
(4) teams and team full of empty conditions
To distinguish team empty or filled cases, there are several treatments:
Embodiment 1: a means to distinguish between the sacrificial teams and team full empty, less a queue enqueue unit time, that is to agreed "next queue head pointer queue tail pointer position as the team full flag."
Team Full conditions: (rear + 1)% QueueSize == front
Team Air condition: front == rear
Queue length: (rear-front ++ QueueSize)% QueueSize
Option 2: additional data representing the number of members of the size of the queue element, at this time, when the full team and the team has an empty front == rear.
Conditions for the full team: size == QueueSize
Team Air conditions: size == 0
Mode 3: additional data tag to differentiate between team members full or empty team
tag represents 0, if the issues leading to delete front == rear, the team empty;
tag is equal to 1, if the issues leading to front == rear is inserted into the full team
Topic two
Array A = array [1..100,1..100] In order row based program storage, provided for each data element occupies two memory cells, the base address is 10, the LOC [5,5] should be.
- 1020
- 1010
- 818
- 808
Explanation:
[(5-1) * 100 + (5-1)] + 2 * 10 = 818, 5 represents a first sequence to conduct, so to column 5 using row 5 used, instead, that the use of A [5] [5] 5 in the second, i.e., (5-1) * 100 (where 100 represents the column, corresponding to a [100] [100] the second 100,), because the rows and columns 1 are from the beginning, so that the rows and columns to be -1, each data element representing 2 storage, so the rows and columns have 2 *, the base address is 10, meaning headed address is 10, so choose 818
Topic three
In Visual C ++ platform and Mingw64
a [100], what sizeof (a) return short
- 2
- 4
- 100
- 200
- 400
Explanation:
short int: 2 bytes
Value represents the meaning of the following return sizeof (in bytes):
Array - an array of the size of the space allocated compiler;
pointer - the pointer to the storage space used (the length of the address stored in the pointer, long integer, should be 4);
Type - the type of space occupied by ;
the object - an object the size of the actual space;
Function - the function's return type of occupied space. The return type of the function can not be void.
Title four
Contains a pointer pointing to declare an array of 10 elements where each element is a function pointer, the function returns the value of int, int * parameter, is correct ()
(int *p[10])(int*) int [10]*p(int *) int (*(*p)[10])(int *) int ((int *)[10])*p Above options are incorrect
Explanation:
First topic that you want to declare an array of pointers, in general we think is just an array of pointers to a int (* p) [10], and then said each element is a function pointer, then we casually to a function pointer int (* pf ) (int *) then (* p) [10] as an alternative to whole pf i.e. int (* (* p.) [10])) (int *); analysis: analyzing a complex formula to see the highest priority , * p is a pointer, then the outside (* p) is [], the array pointer is, (* p) described in [10]) is completed, and then look outside int (*) (int *) obviously, this is a function pointer, so that each element of this array function pointer
Title five
Explanation:
s is the array name, const pointer, immutable; p is a pointer variable B. SUMMARY s array of characters is "china \ 0"; the content is a character pointer p 'c' of the address, to which the content of 'c' C. p character pointer simply stream does not point to a string
Title six
Explanation:
In the interval [1, 30],
Divisible by 2 30/2 = 15,
There are a number divisible by 3 of 30/3 = 10,
5 can be divisible 30/5 = 6,
3 can also be divisible by 2 divisible 30/6 = 5,
5 can also be divisible by 2 divisible 30/10 = 3,
5 can also be divisible by 3 divisible 30/15 = 2,
Divisible by 2, 3 can also be divisible by 5 divisible 30/30 = 1,
The inclusion and exclusion laws set found: A∪B∪C = A + B + C - A ∩ B - B ∩ C - C + A A ∩ ∩ B ∩ C ,
Thus, divisible by 2 or divide by 3 or 5 can be divided by the number of the number of (non-duplicate) as follows: 15 + 10 + 6--5--3--2 + 1 = 22
1500/22 = 68 ????? 4, [1, 30], satisfying the fourth condition is the number 5, and 68 * 30 = 2040, so the number of first 1500
2040 + 5 = 2045
Title seven
Explanation:
1. 定义一维数组时,必须显式指明数组的长度;
2. 定义***数组时,其一维数组的长度必须首先指明,其他维数组长度可以稍后指定;
3. 采用给定值初始化数组时,不必指明长度;
4. “[]” 是数组运算符的意思,在声明一个数组时,数组运算符可以放在数据类型与变量之间,也可以放在变量之后。
题目八
解释:
A忽视了线性表中的第一个元素和和最后一个元素 b,线性表的长度为零时,叫空表 c,按顺序排序的应该是线性表中的特例有序表,不能以偏概全
题目九
解释:
sort() 方法用于对数组的元素进行排序,参数决定排序的顺序。
- 原数组var array=[-1,1,3,4,6,10];
- 参数(a,b)=>Math.abs(a-3)-Math.abs(b-3):即数值减3的绝对值[4,2,0,1,3,7]作为参数决定排序。
- 根据绝对值减3大小排列[0,1,2,3,4,7],对应的原数组排序后为[3,4,1,6,-1,10]
题目十
解释:
sizeof计算长度包括字符串结束符\0
strlen不包括
题目十一
解释:
a11
a21 a22
.
.
a71, a72... a77
以此类推.
那么a11到a77一共有(1+7)*7/2=28个.
a81到a85是5个
所以就是33
题目十二
解释:
注意题目强调的是用 数组 实现的线性表,所以A答案就是访问数组的第i和i-1个元素,B和C是对数组进行插入和删除,需要移动后面的元素,复杂度为O(n)
题目十三
解释:
A[2][2]与A[0][0] 相差两排零2个元素
A[3][3]与A[2][2] 相差一排零1个元素
因为元素的地址是连续的
所以A[2][2]与A[0][0] 的地址差是A[3][3]与A[2][2]地址差的2倍
A[2][2]与A[0][0] 的地址差是676-644
A[3][3]与A[2][2]地址差是(676-644)/2
所以A[3][3]的地址是676+(676-644)/2
题目十四
解释:
float一般为4个字节,以0做下标,计算第15个则不包括第15个,所以只有15个
15*4+200=260,