关键词不能为空

当前您在: 主页 > 高中公式大全 >

欢乐圣诞佳音程序员面试经典试题

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-01-21 04:02
tags:

统计分析报告范文-hostages

2021年1月21日发(作者:刘沧龙)
1
、现有
1000
个苹果,
10
个盒子,问各个盒子内应该 分别放入多少
个苹果,才能使得用户要买任意
1

1000
之间的一 个苹果数,都可
以给他(卖的时候是整个盒子卖,不能拆盒子的包装)



2
、请仔细阅读下面的资料:


1
)材料一:
CArray
template<
class
TYPE,
class
ARG_TYPE
>
class
CArray
:
public
CObject
Parameters:
TYPE
Template parameter specifying the type of objects stored in the array.

TYPE is a parameter that is returned by CArray.
ARG_TYPE
Template parameter specifying the argument type used to access objects
stored in the array.

Often a reference to TYPE. ARG_TYPE is a parameter that is passed to
CArray.
Remarks:
The CArray class supports arrays that are are similar to C arrays, but can
dynamically shrink and grow as necessary.

Array indexes always start at position 0. You can decide whether to fix
the upper bound or allow the array to expand when you add elements past
the current bound. Memory is allocated contiguously to the upper bound,
even if some elements are null.

int CArray::Add (ARG_TYPE newElement);

Return Value:
The index of the added element.
Parameters:
ARG_TYPE
Template
parameter
specifying
the
type
of
arguments
referencing
elements in this array.
newElement
The element to be added to this array.

TYPE& CArray::operator [] (int nIndex);
Parameters:
TYPE
Template parameter specifying the type of elements in this array.
nIndex
Index of the element to be accessed.
Remarks:
Returns the array reference of element at the specified index.

2
)材料二:
CList
templateclass CList : public CObject
Parameters:
TYPE
Type of object stored in the list.
ARG_TYPE
Type used to reference objects stored in the list. Can be a reference.
Remarks:
The
CList
class
supports
ordered
lists
of
nonunique
objects
accessible
sequentially or by value.

CList lists behave like doubly-linked lists.


void CList::AddTail(ARG_TYPE newElement);
Parameters:
ARG_TYPE
Template
parameter
specifying
the
type
of
the
list
element
(can
be
a
reference).
newElement
The element to be added to this list.
Remarks:
Adds a new element or list of elements to the tail of this list. The list can
be empty before the operation.

3
)材料三
: realloc
realloc
Reallocate memory blocks.
void *realloc(void *memblock, size_t size);
Return Value:
The return value points to a storage space that is guaranteed to be suitably
aligned for storage of any type of object. To get a pointer to a type other
than void, use a type cast on the return value.
Remarks:
The size argument gives the new size of the block, in bytes. The contents
of
the
block
are
unchanged
up
to
the
shorter
of
the
new
and
old
sizes,
although the new block can be in a different location. Because the new
block can be in a new memory location, the pointer returned by realloc is
not guaranteed to be the pointer passed through the memblock argument.

4
)请指出下面这段代码可能会出现的问题

CListARIANT*, V
ARIANT*> g_ValueList;
CArrayARIANT, const V
ARIANT&> g_ValuePool;
void AddNewValue (const V
ARIANT& newValue)
{
g_l(&g_ValuePool[g_(newValue)]);
}

3
、有一无符号整型数组,大小为
10,
初始的数值随机,但在
[0,
99]
之间。请用
C
语言写 一个过滤程序,令数组内的数据互不相等。

说明:

1.
若数组内 有相等的数据,可令某一数值加
1
或减
1
作出偏移,直至
不等为止。

2.
数组内的数据只能在
[0, 99]
之间。

3.
保持数组内的数据位置不变,即对应下标不变。


4


按要求编写以下函数。

功能:将给定缓冲区中的
#
字符移到字符串尾部

函数名称:
ChangeToTail
入口参数:
pSZ
指向缓冲区的指针
, nSize
缓冲区长度

出口:
pSZ
所指缓冲区中的
#
字符被移到缓冲区尾部
< br>返回值:
在出口缓冲区中第一个
#
的位置
,
若缓冲区中无#
字符则返回
-1





入< br>#W#W#W#WW#


10








WWWWW#####
并且返回值为
5
int ChangeToTail(BYTE* pSZ, UINT nSize)
{

统计分析报告范文-hostages


统计分析报告范文-hostages


统计分析报告范文-hostages


统计分析报告范文-hostages


统计分析报告范文-hostages


统计分析报告范文-hostages


统计分析报告范文-hostages


统计分析报告范文-hostages



本文更新与2021-01-21 04:02,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/542259.html

程序员面试经典试题的相关文章