-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBTLL.cpp
More file actions
57 lines (53 loc) · 774 Bytes
/
BTLL.cpp
File metadata and controls
57 lines (53 loc) · 774 Bytes
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
#include <iostream>
using namespace std;
typedef struct BTree{
int n=0;
BTree* next=NULL;
}T;
T* newT(){
T* a= new BTree;
return a;
}
int main(){
T* first=newT();
T* node=first;
int a=0,d;
while(true){
cin>>d;
if(d==-1){
break;
}
for(int i=0;i<a;i++){
node=first;
while(node->next!=NULL){
if(node!=first&&node->n==d)d==-2;
node=node->next;
}
}
if(d!=-1&&d!=-2){
node=first;
while(node->next!=NULL){
node=node->next;
}
T* tmp=newT();
node->next=tmp;
node=node->next;
node->n=d;
}
}
while(true){
cin>>d;
int x=0;
if(d==-1)break;
node=first->next;
while(node!=NULL){
if(node->n==d)x=1;
node=node->next;
}
if(x){
cout<<"found"<<endl;
}else{
cout<<"not found"<<endl;
}
}
}