-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhard.c
More file actions
99 lines (97 loc) · 1.87 KB
/
hard.c
File metadata and controls
99 lines (97 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include<stdlib.h>
#include<stdio.h>
void print(void);
truct datast
{
char *info;
// char info[50];
struct datast *right;
struct datast *down;
};
struct datast *root=NULL;
struct datast *temproot=NULL;
void create()
{
int i;
//char *x;
char x[50];
struct datast *q=malloc(sizeof(struct datast));
printf("Enter root info\n");
scanf("%s",x);
q->info=x;
q->right=0;
q->down=0;
root=q;
print();
struct datast *temp=root;
struct datast *tempdwn=root;
int j;
for(i=0;i<2;i++)
{
if(temp!=root)
{
printf("ENter new info\n");
scanf("%s",x);
struct datast *p=malloc(sizeof(struct datast));
p->info=x;
p->down=0;
p->right=0;
temp->right=p;
temp=temp->right;
print();
}
}
printf("\n finished inner for loop");
for(j=0;j<2;j++)
{
printf("Enter root info\n");
scanf("%s",x);
q->info=x;
q->right=0;
q->down=0;
//temproot=q;
tempdwn->down=q;
tempdwn=tempdwn->down;
temp=tempdwn;
print();
for(i=0;i<2;i++)
{
printf("ENter new info\n");
scanf("%s",x);
struct datast *p=malloc(sizeof(struct datast));
p->info=x;
p->down=0;
p->right=0;
temp->right=p;
temp=temp->right;
print();
}
printf("\n finished inner for loop");
//tempdwn=tempdwn->down;
//temp=tempdwn;
}
}
void print()
{
struct datast *temp=root;
struct datast *tempdwn=root;
int i=1;
printf("The root is %s \n",root->info);
// while(tempdwn!=NULL)
{
printf("For %d th row\n",i);
while(temp!=NULL)
{
printf("%s ",temp->info);
temp=temp->right;
}
tempdwn=tempdwn->down;
temp=tempdwn;
i++;
}
}
void main()
{
create();
print();
}