新聞中心
#include
int main()
{
int a[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int xiajie = 0,shangjie= 9;
int zhongjianzhi= 0;
int k= 0;
printf("%d\n", k);
while (xiajie<= shangjie)
{
mid = (xiajie+ shangjie) / 2;
if (x { ?shangje = zhongjianz; } else if (k >zhongjianzhi) { ?xiajie= zhongjianzhi+1; } else? { ?printf("找到%d了\n", k); ?break;? } } } 遍歷 #include #include typedef struct Tree{ int data;? struct Tree *lchild;? struct Tree *rchild; //? }Tree,*BitTree; BitTree CreateLink() { int data; int temp; BitTree T; scanf("%d",&data);? temp=getchar();? if(data == -1){? return NULL; }else{ T = (BitTree)malloc(sizeof(Tree));? T->data = data;? printf("請輸入%d的左子樹: ",data);?? T->lchild = CreateLink();? printf("請輸入%d的右子樹: ",data);? ? T->rchild = CreateLink();? return T;? }? } void ShowXianXu(BitTree T)? { if(T==NULL)? { return; } printf("%d ",T->data); ShowXianXu(T->lchild);? ShowXianXu(T->rchild);? } void ShowZhongXu(BitTree T)? { if(T==NULL)? { return; } ShowZhongXu(T->lchild);? printf("%d ",T->data); ShowZhongXu(T->rchild);? } void ShowHouXu(BitTree T)? { if(T==NULL)? { return; } ShowHouXu(T->lchild);? ShowHouXu(T->rchild);? printf("%d ",T->data); } int main() { BitTree S; printf("請輸入第一個節(jié)點的數據:\\n"); S = CreateLink();? printf("先序遍歷結果: \\n"); ShowXianXu(S);? printf("\\n中序遍歷結果: \\n"); ShowZhongXu(S);? printf("\\n后序遍歷結果: \\n"); ShowHouXu(S);? return 0;? } 你是否還在尋找穩(wěn)定的海外服務器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準確流量調度確保服務器高可用性,企業(yè)級服務器適合批量采購,新人活動首月15元起,快前往官網查看詳情吧
分享題目:折半查找和遍歷-創(chuàng)新互聯(lián)
鏈接分享:http://www.dlmjj.cn/article/phdoe.html