[英]Implementation of n-ary trees in c
有人可以告诉我n元树中的2-D数组到底是用来做什么的吗?
#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数组表示。 它用作存储数据的下划线数据结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.