




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
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級(jí)計(jì)算機(jī)科學(xué)與技術(shù)特色班李徐紅#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<<"輸入元素個(gè)數(shù):"cin>>size;for(int i=0; i<size; i+)cout<<"輸入第"<<i+1<<&q
6、uot;個(gè)數(shù)據(jù)元素:"cin>>datai;template <class ElemType>void DataList<ElemType>:Show(void)cout<<"元素:"for(int i=0; i<size; i+)cout<<datai<<" "cout<<endl;cout<<"元素個(gè)數(shù):"<<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<<"輸入班級(jí)總?cè)藬?shù):"cin>>size;for(int i=0; i<size; i+)cout<<"輸入第"<<i+1<<"個(gè)同學(xué)總成績:"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<<"學(xué)號(hào)"<<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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 預(yù)防校園欺凌班會(huì)課件
- 顧客體驗(yàn)課件
- 心電圖健康評(píng)估與應(yīng)用
- 醫(yī)院學(xué)會(huì)管理辦法解讀
- 音樂課件的作文
- 市政污水管網(wǎng)改造項(xiàng)目環(huán)境影響報(bào)告書(模板)
- 城鎮(zhèn)污水管網(wǎng)建設(shè)項(xiàng)目投資估算方案(參考模板)
- xx河流排水防澇設(shè)施建設(shè)項(xiàng)目節(jié)能評(píng)估報(bào)告(參考)
- 2025年商務(wù)、清洗服務(wù)項(xiàng)目建議書
- 2025年差壓變送器合作協(xié)議書
- 2025年重慶出版集團(tuán)招聘筆試參考題庫含答案解析
- 高一下學(xué)期期末考試物理試題
- 施工現(xiàn)場重大危險(xiǎn)源辨識(shí)及監(jiān)控措施
- DB21T 2414.2-2015 公共場所雙語標(biāo)識(shí)英文譯法 第2部分:道路交通
- 新產(chǎn)品開發(fā)流程
- 2023年高考真題-歷史(遼寧卷) 含解析
- 化工廠消防演練方案
- 2024屆高考語文二輪復(fù)習(xí) 非連續(xù)性文本閱讀 訓(xùn)練(含答案)
- 介紹正畸課件教學(xué)課件
- 職業(yè)衛(wèi)生技術(shù)服務(wù)機(jī)構(gòu)檢測人員考試真題題庫
- 2024年共青團(tuán)團(tuán)課考試測試題庫及答案
評(píng)論
0/150
提交評(píng)論