gpt4 book ai didi

c - N叉树在c中的实现

转载 作者:行者123 更新时间:2023-11-30 17:18:38 24 4
gpt4 key购买 nike

有人可以告诉我n叉树中的二维数组到底有什么用吗?

#include <stdio.h>

int main()
{
int row = 5;//no. of input lines
//1st element in each row is node Value, 2nd - no of child, ,>=3rd....=>value of child
int data[5][6];
int i,j,k,m;
for (i=0;i<5;i++)
{
printf("\nEnter value of Node:\t");
for(j=0;j<6;j++)
{
if(j==1)
printf("\nEnter no of child:\t");
else if(j==2)
printf("\nEnter Values of child\n(if child not present enter 0 as value):\t");
scanf("%d",&data[i][j]);
}
}

最佳答案

看起来你正在谈论的 n 数组树是由 2d 数组表示的。它用作下划线数据结构来存储数据。

关于c - N叉树在c中的实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29132155/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com