#include<stdio.h> #define TREEMAX 100 typedef struct BT { char data; BT *lchild; BT *rchild; }BT; BT *CreateTree(); void Preorder(BT *T); void Postorder(BT *T); void Inorder(BT *T); void Leafnum(BT *T); void Nodenum(BT *T); int TreeDepth(BT *T); int count=0; void main() { BT *T=NULL; char ch1,ch2,a; ch1='y'; while(ch1=='y'||ch1=='y') { printf("\n"); printf("\n\t\t 二叉樹子系統(tǒng)"); printf("\n\t\t*****************************************"); printf("\n\t\t 1---------建二叉樹 "); printf("\n\t\t 2---------先序遍歷 "); printf("\n\t\t 3---------中序遍歷 "); printf("\n\t\t 4---------后序遍歷 "); printf("\n\t\t 5---------求葉子數(shù) "); printf("\n\t\t 6---------求結(jié)點(diǎn)數(shù) "); printf("\n\t\t 7---------求樹深度 "); printf("\n\t\t 0---------返 回 "); printf("\n\t\t*****************************************"); printf("\n\t\t 請選擇菜單號 (0--7)"); scanf("%c",&ch2); getchar(); printf("\n"); switch(ch2) { case'1': printf("\n\t\t請按先序序列輸入二叉樹的結(jié)點(diǎn):\n"); printf("\n\t\t說明:輸入結(jié)點(diǎn)(‘0’代表后繼結(jié)點(diǎn)為空)后按回車。\n"); printf("\n\t\t請輸入根結(jié)點(diǎn):"); T=CreateTree(); printf("\n\t\t二叉樹成功建立!\n");break; case'2': printf("\n\t\t該二叉樹的先序遍歷序列為:"); Preorder(T);break; case'3': printf("\n\t\t該二叉樹的中序遍歷序列為:"); Inorder(T);break; case'4': printf("\n\t\t該二叉樹的后序遍歷序列為:"); Postorder(T);break; case'5': count=0;Leafnum(T); printf("\n\t\t該二叉樹有%d個(gè)葉子。\n",count);break; case'6': count=0;Nodenum(T); printf("\n\t\t該二叉樹總共有%d個(gè)結(jié)點(diǎn)。\n",count);break; case'7': printf("\n\t\t該樹的深度為:%d",TreeDepth(T)); break; case'0': ch1='n';break; default: printf("\n\t\t***請注意:輸入有誤!***"); } if(ch2!='0') { printf("\n\n\t\t按【Enter】鍵繼續(xù),按任意鍵返回主菜單!\n"); a=getchar(); if(a!='\xA') { getchar(); ch1='n'; } } } } BT *CreateTree() { BT *t; char x; scanf("%c",&x); getchar(); if(x=='0') t=NULL; else { t=new BT; t->data=x; printf("\n\t\t請輸入%c結(jié)點(diǎn)的左子結(jié)點(diǎn):",t->data); t->lchild=CreateTree(); printf("\n\t\t請輸入%c結(jié)點(diǎn)的右子結(jié)點(diǎn):",t->data); t->rchild=CreateTree(); } return t; } void Preorder(BT *T) { if(T) { printf("%3c",T->data); Preorder(T->lchild); Preorder(T->rchild); } } void Inorder(BT *T) { if(T) { Inorder(T->lchild); printf("%3c",T->data); Inorder(T->rchild); } } void Postorder(BT *T) { if(T) { Postorder(T->lchild); Postorder(T->rchild); printf("%3c",T->data); } } void Leafnum(BT *T) { if(T) { if(T->lchild==NULL&&T->rchild==NULL) count++; Leafnum(T->lchild); Leafnum(T->rchild); } } void Nodenum(BT *T) { if(T) { count++; Nodenum(T->lchild); Nodenum(T->rchild); } } int TreeDepth(BT *T) { int ldep,rdep; if(T==NULL) return 0; else { ldep=TreeDepth(T->lchild); rdep=TreeDepth(T->rchild); if(ldep>rdep) return ldep+1; else return rdep+1; } }
上傳時(shí)間: 2020-06-11
上傳用戶:ccccy
#include <stdio.h> #include <stdlib.h> #define SMAX 100 typedef struct SPNode { int i,j,v; }SPNode; struct sparmatrix { int rows,cols,terms; SPNode data [SMAX]; }; sparmatrix CreateSparmatrix() { sparmatrix A; printf("\n\t\t請輸入稀疏矩陣的行數(shù),列數(shù)和非零元素個(gè)數(shù)(用逗號隔開):"); scanf("%d,%d,%d",&A.cols,&A.terms); for(int n=0;n<=A.terms-1;n++) { printf("\n\t\t輸入非零元素值(格式:行號,列號,值):"); scanf("%d,%d,%d",&A.data[n].i,&A.data[n].j,&A.data[n].v); } return A; } void ShowSparmatrix(sparmatrix A) { int k; printf("\n\t\t"); for(int x=0;x<=A.rows-1;x++) { for(int y=0;y<=A.cols-1;y++) { k=0; for(int n=0;n<=A.terms-1;n++) { if((A.data[n].i-1==x)&&(A.data[n].j-1==y)) { printf("%8d",A.data[n].v); k=1; } } if(k==0) printf("%8d",k); } printf("\n\t\t"); } } void sumsparmatrix(sparmatrix A) { SPNode *p; p=(SPNode*)malloc(sizeof(SPNode)); p->v=0; int k; k=0; printf("\n\t\t"); for(int x=0;x<=A.rows-1;x++) { for(int y=0;y<=A.cols-1;y++) { for(int n=0;n<=A.terms;n++) { if((A.data[n].i==x)&&(A.data[n].j==y)&&(x==y)) { p->v=p->v+A.data[n].v; k=1; } } } printf("\n\t\t"); } if(k==1) printf("\n\t\t對角線元素的和::%d\n",p->v); else printf("\n\t\t對角線元素的和為::0"); } int main() { int ch=1,choice; struct sparmatrix A; A.terms=0; while(ch) { printf("\n"); printf("\n\t\t 稀疏矩陣的三元組系統(tǒng) "); printf("\n\t\t*********************************"); printf("\n\t\t 1------------創(chuàng)建 "); printf("\n\t\t 2------------顯示 "); printf("\n\t\t 3------------求對角線元素和"); printf("\n\t\t 4------------返回 "); printf("\n\t\t*********************************"); printf("\n\t\t請選擇菜單號(0-3):"); scanf("%d",&choice); switch(choice) { case 1: A=CreateSparmatrix(); break; case 2: ShowSparmatrix(A); break; case 3: SumSparmatrix(A); break; default: system("cls"); printf("\n\t\t輸入錯(cuò)誤!請重新輸入!\n"); break; } if (choice==1||choice==2||choice==3) { printf("\n\t\t"); system("pause"); system("cls"); } else system("cls"); } }
上傳時(shí)間: 2020-06-11
上傳用戶:ccccy
某疾病發(fā)生率y‰和年齡段x(每五年為一段,例如0~5歲為第一段..)
標(biāo)簽: C代碼
上傳時(shí)間: 2020-06-14
上傳用戶:ll12346
第一種邊界條件下的三次樣條插值問題(高斯消元法) 題目 計(jì)算方法上機(jī)實(shí)習(xí)題目(二) ——第一種邊界條件下的三次樣條插值問題(高斯消元法) 已知直升飛機(jī)旋轉(zhuǎn)機(jī)翼外形曲線輪廓線上的某些型值點(diǎn)(見表)及端點(diǎn)處的一階導(dǎo)數(shù)值 y' (x ) = 1.86548, y' (x ) = -0.046115
標(biāo)簽: 計(jì)算方法上機(jī)實(shí)習(xí)題目
上傳時(shí)間: 2020-06-27
上傳用戶:zg250
x=[1,2,0,-1,3,2];h=[1,-1,1]; y1=x*h(1); y2=x*h(2); y3=x*h(3); Y1=[0,0,y1]; Y2=[0,y2,0]; Y3=[y3,0,0]; y=Y1+Y2+Y3; L=-2:1:5; figure(1); subplot(211);stem(L,y,'*'); xlabel('L');ylabel('y');title('(1)'); X=x.';X=X'; r1=X*y(1);r2=X*y(2);r3=X*y(3);r4=X*y(4); r5=X*y(5);r6=X*y(6);r7=X*y(7);r8=X*y(8); R1=[0,0,0,0,0,0,0,r1];R2=[0,0,0,0,0,0,r2,0]; R3=[0,0,0,0,0,r3,0,0];R4=[0,0,0,0,r4,0,0,0]; R5=[0,0,0,r5,0,0,0,0];R6=[0,0,r6,0,0,0,0,0]; R7=[0,r7,0,0,0,0,0,0];R8=[r8,0,0,0,0,0,0,0]; R=R1+R2+R3+R4+R5+R6+R7+R8; n=-7:5; subplot(212);stem(n,R);title('(2)');
標(biāo)簽: ketang
上傳時(shí)間: 2020-11-10
上傳用戶:
本設(shè)計(jì)方案中我采用多路復(fù)用器,2-4譯碼器,LED燈和或門等器件來完成設(shè)計(jì)。用2個(gè)74x151多路復(fù)用器擴(kuò)展為16-2多路復(fù)用器,題目中的地址代碼A、B、C、D4個(gè)輸入端作為擴(kuò)展的多路復(fù)用器的地址端,DO-D8作為數(shù)據(jù)端。開箱鑰匙孔信號E作為2-4decoder的使能端。設(shè)計(jì)開鎖的正確代碼為0101,當(dāng)用鑰匙開鎖(即2-4decoder的使能端有效〉時(shí),如果正確輸入開鎖密碼:0101,則輸出Y為邏輯高電平,Y’為邏輯低電平,鎖被打開,而LED燈不會(huì)亮(即不會(huì)報(bào)警);如果輸入的密碼錯(cuò)誤或者鑰匙孔信號無效,則輸出Y為邏輯低電平,Y’為邏輯高電平,鎖無法打開,邏輯高電平Y(jié)’驅(qū)動(dòng)LED燈亮,產(chǎn)生報(bào)警效果。2.設(shè)計(jì)原理圖:(以下電路圖為用QuartusI蹤合后截屏所得) 本設(shè)計(jì)方案中我采用多路復(fù)用器,2-4譯碼器,LED燈和或門等器件來完成設(shè)計(jì)。用2個(gè)74x151多路復(fù)用器擴(kuò)展為16-2多路復(fù)用器,題目中的地址代碼A、B、C、D4個(gè)輸入端作為擴(kuò)展的多路復(fù)用器的地址端,DO-D8作為數(shù)據(jù)端。開箱鑰匙孔信號E作為2-4decoder的使能端。設(shè)計(jì)開鎖的正確代碼為0101,當(dāng)用鑰匙開鎖(即2-4decoder的使能端有效〉時(shí),如果正確輸入開鎖密碼:0101,則輸出Y為邏輯高電平,Y’為邏輯低電平,鎖被打開,而LED燈不會(huì)亮(即不會(huì)報(bào)警);如果輸入的密碼錯(cuò)誤或者鑰匙孔信號無效,則輸出Y為邏輯低電平,Y’為邏輯高電平,鎖無法打開,邏輯高電平Y(jié)’驅(qū)動(dòng)LED燈亮,產(chǎn)生報(bào)警效果。2.設(shè)計(jì)原理圖:(以下電路圖為用QuartusI蹤合后截屏所得)
標(biāo)簽: 密碼鎖
上傳時(shí)間: 2021-04-26
上傳用戶:情可傾想
復(fù)活節(jié)計(jì)算 int y, n, a, q, b, m, w, d, mm = 4; y = atoi(argv[1]); n = y-1900; a = fmod(n,19);
上傳時(shí)間: 2021-07-09
上傳用戶:scfan2004
THIS PUBLICATION IS COPYRIGHT PROTECTEDCopyright ? 2014 IEC, Geneva, SwitzerlandAll rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized in any formor by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing fromeither IEC or IEC's member National Committee in the country of the requester. If you have any questions about IECcopyright or have an enquiry about obtaining additional rights to this publication, please contact the address below oryour local IEC member National Committee for further information.Droits de reproduction réservés. Sauf indication contraire, aucune partie de cette publication ne peut être reproduiteni utilisée sous quelque forme que ce soit et par aucun procédé, électronique ou mécanique, y compris la photocopieet les microfilms, sans l'accord écrit de l'IEC ou du Comité national de l'IEC du pays du demandeur. Si vous avez desquestions sur le copyright de l'IEC ou si vous désirez obtenir des droits supplémentaires sur cette publication, utilisezles coordonnées ci-après ou contactez le Comité national de l'IEC de votre pays de résidence.
標(biāo)簽: iec標(biāo)準(zhǔn)
上傳時(shí)間: 2021-10-21
上傳用戶:kent
示波器是利用電子示波管的特性,將人眼無法直接觀測的交變電信號轉(zhuǎn)換成圖像,顯示在熒光屏上以便測量的電子測量儀器。它是觀察數(shù)字電路實(shí)驗(yàn)現(xiàn)象、分析實(shí)驗(yàn)中 的問題、測量實(shí)驗(yàn)結(jié)果必不可少的重要儀器。示波器由示波管和電源系統(tǒng)、同步系統(tǒng)、X軸偏轉(zhuǎn)系統(tǒng)、Y軸偏轉(zhuǎn)系統(tǒng)、延遲掃描系統(tǒng)、標(biāo)準(zhǔn)信號源組成。
標(biāo)簽: 示波器
上傳時(shí)間: 2021-11-27
上傳用戶:得之我幸78
Mathlab發(fā)行的圖形計(jì)算器應(yīng)用于安卓設(shè)備的高品質(zhì)顯示屏上,對用戶來說,計(jì)算更加清晰易懂且一目了然。這個(gè)程序有兩大優(yōu)勢:首先,它不僅是一個(gè)精細(xì)的科學(xué)計(jì)算器,而且更重要的是,它在您輸入過程中顯示計(jì)算步驟,可以讓學(xué)生觀看和學(xué)習(xí)如何得出最終答案。第二,它的圖形顯示能力超乎尋常!不僅計(jì)算器顯示圖精美,而且會(huì)自動(dòng)并顯示生成x和y的值。本軟件適用于Android平臺專業(yè)版的功能* 3D圖形* 全屏* 9的工作區(qū)域* 保存常量和函數(shù)庫* 不要求因特網(wǎng)* 沒有廣告科學(xué)計(jì)算器* 算術(shù)表達(dá)式 +, - ,*,/,÷* 平方根,立方和多次方根 (保持‘√’密鑰)* 指數(shù),對數(shù) (ln,log)* 三角函數(shù)sin π/2,cos 30°,...* 雙曲線函數(shù):正弦,余弦,正切,...(按“e”鍵切換)* 反函數(shù)(按直接功能鍵)* 復(fù)數(shù),所有功能都支持復(fù)數(shù)* 導(dǎo)數(shù) sin x' = cos x,... (按 x^n 鍵)* 科學(xué)記數(shù)法(在菜單中啟用)* 百分比模式* 保存/載入歷史圖形計(jì)算器* 多種功能繪圖* 隱函數(shù)的第二度(橢圓 2x^2+3y^2=1,等等)* 極性圖 (r=cos2θ)* 參數(shù)函數(shù),輸入新線 (x=cos t,y=sin t)* 功能根和交叉點(diǎn)的圖表,請點(diǎn)選的傳說開啟和關(guān)閉(左上角),使用菜單顯示為一個(gè)列表* 圖交叉口 (x^2=x+1)* 跟蹤函數(shù)值和斜坡* 滾動(dòng)和縮放圖表* 捏放大* 橫向全屏圖* 函數(shù)表* 保存為圖像圖形* 表保存為 CSV分?jǐn)?shù)計(jì)算器* 簡單和復(fù)雜的分?jǐn)?shù) 1/2+1/3=5/6* 混合數(shù)字時(shí),使用空格輸入值 3 1/2代數(shù)計(jì)算器* 線性方程 x+1=2 -> x=1* 二次方程 x^2-1= 0 -> x=-1,1* 較高多項(xiàng)式近似根* 系統(tǒng)線性方程組,每行寫一個(gè)方程式,x1+x2=1,x1-x2=2* 多項(xiàng)式長除法* 多項(xiàng)式展開,多項(xiàng)式展開,因式分解矩陣計(jì)算器* 矩陣和向量運(yùn)算* 點(diǎn)擊點(diǎn)積 (按住*),多種功能的圖形* 行列式,逆,規(guī)范,移調(diào),跟蹤庫自定義* 用戶定義的常量和函數(shù)* 保存/加載表達(dá)式
上傳時(shí)間: 2021-12-12
上傳用戶:XuVshu
蟲蟲下載站版權(quán)所有 京ICP備2021023401號-1