C ++ 谁来帮忙写个程序啊.......... 一定 追加悬赏。。

CreateaclasscalledSeq-list.Theclasshasthefollowingproperties:DataAnonnegativeintegers... Create a class called Seq-list. The class has the following properties:

Data
A non negative integer specifying the number of items currently in the list (size), and a list of data items.

Operations

Constructor
Initial values: None
Process: Set the size of the list to 0.

List Size
Input: None
Preconditions: None
Process: Read the size of the list.
Output: The list size.
Post conditions: None

List Empty
Input: None
Preconditions: None
Process: Check the size of the list.
Output: Return TRUE if the list is empty; otherwise return FALSE.
Post-conditions: None

Clear List
Input: None
Preconditions: None
Process: Remove all elements from the list and set the list size to 0.
Output: None
Post conditions: The list is empty.

Find
Input: An item to locate in the list.
Preconditions: None
Process: Scan the list for a match.
Output: If the match fails, return FALSE; if the match occurs,
return TRUE.
Post conditions: None

Insert
Input: Item to insert in the list.
Preconditions: None
Process: Add the item at the rear of the list.
Output: None
Post conditions: The list has a new item; its size increases by 1.

Delete
Input: Value to delete from the list.
Preconditions: None
Process: Scan the list and remove the first
occurrence of the item in the list.
Take no action if the item is not in
the list.
Output: None
Post conditions: If a match occurs, the list has one fewer items.

Delete Front
Input: None
Preconditions: List must not be empty.
Process: Remove the first item from the list.
Output: Return the value of the item that is removed.
Post conditions: The list has one fewer items.

Get Data
Input: A position (pos) in the list.
Preconditions: An access error is generated if pos is less than 0 or greater than size.
Process: Extract the value at location pos in the list.
Output: The value of the item at position pos.
Post conditions: None

The class should be declared as follows:

class Seq-list {
private:
// list storage array and number of current list elements
Data Type list item[ARRAY SIZE];
int size;

public:
// constructor
Seq List(void);

// list access methods
int List Size(void) const;
Boolean List Empty(void) const;
Boolean Find (Data Type& item) const;
Data Type Get Data (int pos) const;

// list modification methods
void Insert (const Data Type& item);
void Delete (const Data Type& item);
Data Type Delete Front (void);
void Clear List (void);
};

Be sure and add test cases to the main function to test the functionality of the class.

Note that you will need to declare Data Type using a type def statement. You will also need to define ARRAY SIZE using a #define or the preferable const.
Hint

See the following for the Boolean implementation:

1 // Boolean example
2
3 #include<iostream>
4 using namespace std;
5 #define TRUE 1
6 #define FALSE 0
7 typedef int Boolean;
8
9 int main() {
10
11 Boolean stuff, more_stuff;
12 double x = 2.0, y = 3.0;
13
14 if(x == y) stuff = TRUE;
15 if(x != y) more_stuff = FALSE;
16
17 if(stuff) cout << "x is equal to y" << endl;
18 if(more_stuff) cout << "x is not equal to y" << endl;
19
20 return 0;
21 }
展开
 我来答
小何才露尖尖角儿
2012-04-04 · TA获得超过362个赞
知道小有建树答主
回答量:344
采纳率:0%
帮助的人:387万
展开全部
#include"你的头文件"
#include <assert.h>
#include <iostream>
using namespace std;
// constructor
Seq_list::Seq_list(void)
{
list = NULL;
size = 0;
}

// list access methods
int Seq_list::Size(void)const
{
return size;
}
Boolean Seq_list::Empty(void)const
{
if (size == 0)
{
return true;
}
else
{
return false;
}
}
Boolean Seq_list::Find (DataType& item) const
{
DataType *p = list;
while (p!=NULL)
{
if (item.value == p->value)
{
return true;
}
else
{
p = p->next;
}
}
return false;
}
DataType Seq_list::GetData (int pos) const
{
assert(pos<size);
int i = 0;
DataType *p = list;
while (i<pos)
{
p = p->next;
}
return *p;
}

// list modification methods
void Seq_list::Insert (const DataType& item)
{
if (list == NULL)
{
list = new DataType;
list->value = item.value;
list->next = NULL;
size++;
return;
}
while (list->next)
{
list = list->next;
}
DataType *p = new DataType;
p->value = item.value;
p->next = NULL;
list->next = p;
size++;
}
void Seq_list::Delete (const DataType& item)
{
if (list == NULL)
{
return;
}
while (list->next)
{
if (list->next->value == item.value)
{
DataType *p = list->next;
list->next = list->next->next;
delete p;
size--;
return;
}
else
{
list= list->next;
}
}
}
DataType Seq_list::DeleteFront (void)
{
if (list == NULL)
{
assert(size == 0);
}
else
{
DataType data;
data = *list;
data.next = NULL;
DataType *p = list;
list = list->next;
delete p;
size --;
return data;
}
}
void Seq_list::ClearList (void)
{
DataType *p = list;
while (list!= NULL)
{ p = list;
list = list->next;
delete p;
}
size =0;
}
//下面是头文件:
#ifndef __SEQ_LIST_H__
#define __SEQ_LIST_H__
typedef struct Data_Type
{
int value;
struct Data_Type *next;

}DataType;

#define ARRAY_SIZE 500;
#define Boolean int

class Seq_list {
private:
// list storage array and number of current list elements
DataType *list;
int size;

public:
// constructor
Seq_list(void);

// list access methods
int Size(void) const;
Boolean Empty(void) const;
Boolean Find (DataType& item) const;
DataType GetData (int pos) const;

// list modification methods
void Insert (const DataType& item);
void Delete (const DataType& item);
DataType DeleteFront (void);
void ClearList (void);
};

#endif
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友1fc36d4
2012-04-04 · TA获得超过3131个赞
知道大有可为答主
回答量:1497
采纳率:100%
帮助的人:1826万
展开全部
你的问题补充和题没什么搭关。

#include <iostream>
using namespace std;

typedef int Data_Type;
typedef int Boolean;

#define ARRAY_SIZE 50
#define TRUE 1
#define FALSE 0

class Seq_List {
private:
// list storage array and number of current list elements
Data_Type list_item[ARRAY_SIZE];
int size;

public:
// constructor
Seq_List(void);

// list access methods
int List_Size(void) const;
Boolean List_Empty(void) const;
Boolean Find(Data_Type& item) const;
Data_Type Get_Data(int pos) const;

// list modification methods
void Insert(const Data_Type& item);
void Delete(const Data_Type& item);
Data_Type Delete_Front(void);
void Clear_List(void);
// list view methods
void Print(void);
};

Seq_List::Seq_List(void)
{
size=0;
}

int Seq_List::List_Size() const
{
return size;
}

Boolean Seq_List::List_Empty(void) const
{
return size==0?TRUE:FALSE;
}

Boolean Seq_List::Find(Data_Type& item) const
{
for(int n=0;n<size;n++)
{
if(item==list_item[n]) return TRUE;
}
return FALSE;
}

Data_Type Seq_List::Get_Data(int pos) const
{
if(pos<1||pos>=size)
throw out_of_range("pos is out of range.");
return list_item[pos];
}

// list modification methods
void Seq_List::Insert(const Data_Type& item)
{
if(size>=ARRAY_SIZE) return;
list_item[size++]=item;
}

void Seq_List::Delete(const Data_Type& item)
{
int n;
for(n=0;n<size;n++)
{
if(list_item[n]==item) break;
}
if(n!=size)
{
for(;n<size-1;n++)
{
list_item[n]=list_item[n+1];
}
size--;
}
}

Data_Type Seq_List::Delete_Front(void)
{
Data_Type item;
if(size<1)
throw out_of_range("empty list.");
item=list_item[0];
for(int n=0;n<size-1;n++)
{
list_item[n]=list_item[n+1];
}
size--;
return item;
}

void Seq_List::Clear_List(void)
{
size=0;
}

void Seq_List::Print(void)
{
cout<<"list data:";
if(size==0)
{
cout<<"empty list";
}
for(int n=0;n<size;n++)
{
cout<<list_item[n]<<" ";
}
cout<<endl;
}

int main()
{
Boolean status;
Seq_List list;
Data_Type item;
int i,n;

status=list.List_Empty();
if(status==TRUE) cout<<"list is empty"<<endl;
else list.Print();

cout<<"How many data would you like to input:";
cin>>n;
for(i=0;i<n;i++)
{
cin>>item;
list.Insert(item);
}
n=list.List_Size();
cout<<"list contains "<<n<<" data."<<endl;
list.Print();

cout<<"input a data that you want to find in the list:";
cin>>item;
status=list.Find(item);
if(status==TRUE) cout<<item<<" is found."<<endl;
else cout<<item<<" is not found."<<endl;

cout<<"input the index of data that you want to get:";
cin>>n;
item=list.Get_Data(n);
cout<<"the data of index "<<n<<" is "<<item<<endl;

cout<<"input the data that you want to delete:";
cin>>item;
list.Delete(item);
list.Print();

item=list.Delete_Front();
cout<<"now, delete the front data: "<<item<<endl;
list.Print();

cout<<"now,clear th list..."<<endl;
list.Clear_List();
list.Print();

cin.get();
cin.get();
return 0;
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
抗鸿德8A
2012-04-03 · 超过35用户采纳过TA的回答
知道答主
回答量:121
采纳率:0%
帮助的人:62.9万
展开全部
。。 这是考c++还是考英语。。 除了题目。。 敢不敢再给点汉字。。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
滨崎步最爱
2012-04-04 · TA获得超过665个赞
知道小有建树答主
回答量:705
采纳率:0%
帮助的人:458万
展开全部
一个小链表而已,有空写
追问
大哥,, 今天晚上之前写完行吗,,我在美国上数学专业,,可我们必须学C++ 这个。。。明天我们就交作业了........ 我保证追加悬赏
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
若凉aH
2012-04-04 · 超过18用户采纳过TA的回答
知道答主
回答量:103
采纳率:0%
帮助的人:44.8万
展开全部
我晕,这题真长,还都是英文,我看不懂,您还是另请高明吧!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(3)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式