




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include<iostream>using namespace std;void main()int p,q;cout<<"请输入p和q的值:"<<endl;cin>>p>>q;cout<<"输出p的否定是:"<<!p<<endl;cout<<"输出p的否定是:"<<!q<<endl;cout<<"输出p与q的合取是:"<<(p&&q)<
2、;<endl;cout<<"输出p与的析取是:"<<(p|q)<<endl;cout<<"输出p与q的条件式是:"<<(!p)|q)<<endl;if(p=0&&q=0)|(p!=0&&q!=0)cout<<"输出p与q的双条件是:1"<<endl;elsecout<<"输出p与q的双条件是:0"<<endl;11级计算机科学与技术特色班李徐红#define
3、MAX_SIZE 100#include<iostream>const int SIZE=6;using namespace std;template <class ElemType>class DataListprivate:ElemType dataMAX_SIZE;int size;void Swap(const int mark1, const int mark2);public:DataList(int sz=6):size(sz) ;DataList(void) ;void SelectSort(void);void Input(void);void Sho
4、w(void);template <class ElemType>void DataList<ElemType>:Swap(const int mark1,const int mark2)ElemType temp;temp=datamark1;datamark1=datamark2;datamark2=temp;template <class ElemType>void DataList<ElemType>:SelectSort(void)for(int i=0;i<size-1;i+)int currLargePos=i;for(int
5、 j=i+1; j<size; j+)if(dataj<datacurrLargePos)currLargePos=j;if(currLargePos!=i)Swap(currLargePos,i);template <class ElemType>void DataList<ElemType>:Input(void)cout<<"输入元素个数:"cin>>size;for(int i=0; i<size; i+)cout<<"输入第"<<i+1<<&q
6、uot;个数据元素:"cin>>datai;template <class ElemType>void DataList<ElemType>:Show(void)cout<<"元素:"for(int i=0; i<size; i+)cout<<datai<<" "cout<<endl;cout<<"元素个数:"<<size<<endl;int main(void)DataList<int>
7、 List(SIZE);List.Input();cout<<"排序前:"<<endl;List.Show();List.SelectSort();cout<<"排序后:"<<endl;List.Show();system("PAUSE");return 0;#include<iostream>/using namespace std;template<class ElemType>bool SqList<Elemtype>:Full()constre
8、turn count=maxSize;template<class ElemType>void SqList<ElemType>:Init(int size)maxSize=size;if(elems!=NULL)delete elems;elems=new ElemTypemaxSize;count=0;template<class ElemType>SqList<ElemType>:SqList(int size)elems=NULL;Init(size);template<class ElemType>Sqlist<Ele
9、mType>:SqList()deleteelems;template<class ElemType>int SqList<ElemType>:Length()constreturn count;template<class ElemType>bool SqList<ElemType>:empty()constreturn count=o;template<class ElemType>void SqList<ElemType>:Clear()count=0;template<class ElemType>
10、;void SqList<ElemType>:Traverse(void(*visit)(ElemType &)for(int curPosition=1; curPosition<=Length(); curPosition+)(*visit)(elems curPosition-1);template<class ElemType>StatusCode SqList<ElemType>:GetElem(int position,ElemType &e)constif(position<1|position>Length(
11、)return NOT PRESENT;elsee=elemsposition-1;return ENTRY FOUND;template<class ElemType>StatusCode SqList<ElemType>:SetElem(int position,const ElemType &e)if(position<1|position>Length()return RANGE ERROR;elseelemsposition-1=e;return SUCCESS;#define MAX_SIZE 100#include<iostrea
12、m>const int SIZE=6;using namespace std;template <class ElemType>class DataListprivate:ElemType dataMAX_SIZE;int size;void Swap(const int mark1, const int mark2);public:DataList(int sz=6):size(sz) ;DataList(void) ;void SelectSort(void);void Input(void);void Show(void);template <class Elem
13、Type>void DataList<ElemType>:Swap(const int mark1,const int mark2)ElemType temp;temp=datamark1;datamark1=datamark2;datamark2=temp;template <class ElemType>void DataList<ElemType>:SelectSort(void)for(int i=0;i<size-1;i+)int currLargePos=i;for(int j=i+1; j<size; j+)if(dataj&
14、lt;datacurrLargePos)currLargePos=j;if(currLargePos!=i)Swap(currLargePos,i);template <class ElemType>void DataList<ElemType>:Input(void)cout<<"输入班级总人数:"cin>>size;for(int i=0; i<size; i+)cout<<"输入第"<<i+1<<"个同学总成绩:"cin>>da
15、tai;template <class ElemType>void DataList<ElemType>:Show(void)cout<<"成绩"for(int i=0; i<size; i+)cout<<datai<<" "cout<<endl;cout<<"学号"<<size<<endl;int main(void)DataList<int> List(SIZE);List.Input();cout<
16、<"排序前:"<<endl;List.Show();List.SelectSort();cout<<"排序后:"<<endl;List.Show();system("PAUSE");return 0;#include<iostream>using namespace std;class SqListprotected:int count;int maxSize;ElemType *elems;bool Full() const;void Init(int size);public:
17、SqList(int size=DEFAULT SIZE);virtualSqList();int Length()const;bool Empty()const;void Clear();void Traverse(void(*visit)(const ElemType &)const;StatusCode GetElem(int position,ElemType &e)const;StatusCode SetElem(int position,const ElemType &e);StatusCode Delete(int position,ElemType &a
18、mp;e);StatusCode Insert(int position,const ElemType &e);SqList(const SqList<ElemType>©);SqList<ElemType>&operator=(const SqList<ElemType>©);template<class ElemType>bool SqList<Elemtype>:Full()constreturn count=maxSize;template<class ElemType&g
19、t;void SqList<ElemType>:Init(int size)maxSize=size;if(elems!=NULL)delete elems;elems=new ElemTypemaxSize;count=0;template<class ElemType>SqList<ElemType>:SqList(int size)elems=NULL;Init(size);template<class ElemType>Sqlist<ElemType>:SqList()deleteelems;template<class
20、 ElemType>int SqList<ElemType>:Length()constreturn count;template<class ElemType>bool SqList<ElemType>:empty()constreturn count=o;template<class ElemType>void SqList<ElemType>:Clear()count=0;template<class ElemType>void SqList<ElemType>:Traverse(void(*vis
21、it)(ElemType &)For#include<iostream.h>using namespace std;template<class ElemType>class SqListprotected:int count;int maxsize;ElemType *elems;bool Full()const;void Init(int size);public:SqList(int size=DEFAULT SIZE);virtualSqList();int Length()const;bool Empty const;void Clear();void
22、 Traverse(void(*visit)(const ElemType &)const;StatusCode GetElem(int position,ElemType &e)const;StatusCode SetElem(int position,ElemType &e)const;StatusCode Delete(int position,ElemType &e)const;StatusCodeInsert(int position,const ElemType &e);SqList(const SqList<ElemType>&
23、amp;copy);bool SqList<ElemType>:Full()constreturn count=maxSize;template<class ElemType>void SqList<ElemType>:Init(int size)maxSize=size;if(elems!=NULL) delete elems;elems=new ElemTypemaxSize;count=0;template<class ElemType>SqList<ElemType>:SqList(int size)elems=NULL;template<class ElemType>SqList<ElemType>:SqList()delete elems;template<class ElemType>/int SqList<Ele
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论