Find Jobs
Hire Freelancers

C++ Recursive Array Problem

$10-15 USD

已完成
已发布将近 21 年前

$10-15 USD

货到付款
Write a recursive array-based implementation of the retrieval operation for the ADT list given in the attached file (and copied below). The operation should take the array, an item and the size of the array as parameters and return the position of the item. Be sure that the function calls itself with a smaller problem size. //Header File const int MAX_LIST = 10; typedef int listItemType; class listClass { public: listClass(); //list operations: bool ListIsEmpty() const; int ListLength() const; void ListInsert(int NewPosition, listItemType NewItem, bool& Success); void ListDelete(int Position, bool& Success); void ListRetrieve(int Position, listItemType& DataItem, bool& Success) const; private: listItemType Items[MAX_LIST]; int Size; int Index(int Position) const; }; //CPP File #include "ListA.h" listClass::listClass() : Size(0) { } bool listClass::ListIsEmpty() const { return bool(Size == 0); } int listClass::ListLength() const { return Size; } void listClass::ListInsert(int NewPosition, listItemType NewItem, bool& Success) { Success = bool( (NewPosition >= 1) && (NewPosition <= Size+1) && (Size < MAX_LIST)); if (Success) { for (int Position = Size; Position >= NewPosition; --Position) { Items[Index(Position+1)] = Items[Index(Position)]; } Items[Index(NewPosition)] = NewItem; ++Size; } } void listClass::ListDelete(int Position, bool& Success) { Success = bool((Position >= 1) && (Position <= Size)); if (Success) { for (int FromPosition = Position+1; FromPosition <= Size; ++FromPosition) { Items[Index(FromPosition-1)] = Items[Index(FromPosition)]; } --Size; } } void listClass::ListRetrieve(int Position, listItemType& DataItem, bool& Success) const { Success = bool((Position >= 1) && (Position <= Size)); if (Success) { DataItem = Items[Index(Position)]; } } int listClass::Index(int Position) const { return Position-1; } ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Complete ownership and distribution copyrights to all work purchased. ## Platform Windows
项目 ID: 2961027

关于此项目

4提案
远程项目
活跃21 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
See private message.
$5 USD 在5天之内
4.9 (94条评论)
4.3
4.3
4威客以平均价$8 USD来参与此工作竞价
用户头像
See private message.
$12.75 USD 在5天之内
4.9 (175条评论)
5.9
5.9
用户头像
See private message.
$10.20 USD 在5天之内
5.0 (10条评论)
2.8
2.8
用户头像
See private message.
$5.10 USD 在5天之内
0.0 (0条评论)
0.0
0.0

关于客户

UNITED STATES的国旗
United States
5.0
6
会员自8月 7, 2003起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。