-
Notifications
You must be signed in to change notification settings - Fork 0
/
56_C.cpp
78 lines (71 loc) · 1.05 KB
/
56_C.cpp
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
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
using namespace std;
struct node
{
node* a[1002];
char* s[100];
};
node* makeTree(node* root,string& s)
{
cout<<s<<endl;
if(!root)
{
root = (node*)malloc(sizeof(node));
memset(root->a,0,sizeof(root->a));
}
int t = 0;
while(s!="")
{
if(s[0]==',')
s.erase(0,1);
string m;
bool sawDot = false;
bool sawColon = false;
int dot = 0;
int colon = 0;
for(int i=0;i<(int)s.length();i++)
{
if(s[i]=='.')
{
sawDot = true;
dot = i;
break;
}
if(s[i]==':')
{
sawColon = true;
colon = i;
break;
}
}
if(sawDot)
{
//root->s = (s.substr(0,dot));
s.erase(0,dot+1);
return root;
}
else
{
cout<<colon<<endl;
cout<<"dw"<<" "<<s.substr(0,colon)<<endl;
//root->s = s.substr(0,colon);
s.erase(0,colon+1);
cout<<" "<<s<<endl;
root->a[t] = makeTree(root->a[t],s);
}
t++;
}
return root;
}
int main()
{
string s;
cin>>s;
node* root = NULL;
root = makeTree(root,s);
//cout<<solve(root)<<endl;
return 0;
}