資源簡介
由用戶輸入n個10以內的數,每輸入i(0=<i<=9),就把它插入到第i號隊列中。最后把10個隊列中非空隊列,按隊列號從小到大的順序串成一個鏈,并輸出該鏈的所有元素。
數據結構上機作業 第二章14 張憲超
代碼片段和文件信息
//#include?
#include
using?namespace?std;
const?int?MaxSize=10;
const?int?MaxQNode=10;
typedef?struct?node{
????int?data;
????node?*next;
}QNode;
void?Insert(QNode?*QH[]QNode?*QT[]int?x){
????QNode?*s;
????s=new?QNode;
????s->data=x;
????s->next=NULL;
????if(QH[x]==NULL){
????????QH[x]=s;
????????QT[x]=s;
????}
????else{
????????QT[x]->next=s;
????????QT[x]=s;
????}
}
void?Create(QNode?*QH[]QNode*?QT[]){
????int?nxi;
????cout<<“input?n(n<10):?“;
????cin>>n;
????cout<
????for(i=0;i ????????do{
????????????cout<<“input?no.“<????????????cin>>x;
????????}while(x<0||x>10);
????????Insert(QHQTx);
????}
}
void?link(QNode?*QH[]QNode*QT[])
- 上一篇:C++ Builder利用PDFLib生成PDF文檔
- 下一篇:三維圖像區域生長
評論
共有 條評論