-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
187 lines (184 loc) · 3.66 KB
/
Copy pathmain.cpp
File metadata and controls
187 lines (184 loc) · 3.66 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include "DataStructures.h"
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
//void PascalTriangle()
//{
// int max, s;
// Queue_1<int> q;
// cout << "max rows:";
// cin >> max;
// q.push(1);
// for (int i = 0; i < max; i++)
// cout << setw(3) << ' ';
// cout << setw(3) << q.front() << endl;
// for (int i = 1; i < max; i++) //output rows from 2 to max
// {
// for (int k = 0; k < max - i; k++)
// cout << setw(3) << ' ';
// s = 0;
// for (int j = 0; j < i; j++) //out put item from 1 to i-1
// {
// int x = q.front();
// q.pop();
// q.push(s + x);
// cout << setw(3) << s + x
// << setw(3) << ' ';
// s = x;
// }
// cout << setw(3) << '1' << endl;
// q.push(1);
// }
//}
//bool isNum(char n)
//{
// if (n >= '0' && n <= '9')
// return true;
// return false;
//}
//int getNum(string exp, int &i) //获取连续数字
//{
// Stack_1<int> temp;
// int s = 0;
// while (true)
// {
// char current = exp[i];
// if (!isNum(current)) //连续数字全部读取
// {
// int size = temp.size();//size会变 要先确定
// for (int j = 0; j < size; j++)
// {
// s += temp.top() * pow(10, j);
// temp.pop();
// }
// i--; //指向最后一位数字
// return s;
// }
// temp.push(current - 48);
// i++;
// }
//}
//int caculate(string exp)
//{
// Stack_1<char> operators;
// Stack_1<int> data;
// map<char, int> comp; //处理优先级
// comp['*'] = 3; comp['/'] = 3;
// comp['+'] = 2; comp['-'] = 2;
// comp['('] = 1;
// comp['#'] = 0;
//
// for (int i=0; i < exp.size(); i++)
// {
// char current = exp[i];
// if (current == ' ')
// continue;
// if (current == '#' && operators.empty())
// {
// operators.push(current);
// continue;
// }
//
// if (isNum(current)) //处理连续数字
// {
// data.push(getNum(exp, i));
// continue;
// }
// else
// {
// if (current == '(')
// {
// operators.push(current);
// continue;
// }
// if (comp[operators.top()] >= comp[current])
// {
// int s2 = data.top();
// data.pop();
// int s1 = data.top();
// data.pop();
// switch (operators.top())
// {
// case '+':
// data.push(s1 + s2); break;
// case '-':
// data.push(s1 - s2); break;
// case '*':
// data.push(s1 * s2); break;
// case '/':
// data.push(s1 / s2); break;
// default:
// break;
// }
// operators.pop();
// if (operators.top() == '(')
// {
// operators.pop();
// continue;
// }
// else if (operators.top() == '#') //finish
// return data.top();
// operators.push(current);
// }
// else
// operators.push(current);
// }
// }
//}
List<int> sort(List<int> L)
{
node<int> * m = L.start(), *p = m;
for (int i =0; i < L.size(); i++)
{
while (p->next->next->next != nullptr)
{
node<int> * p1 = p->next, * p2 = p1->next;
if (p2->data > p1->data)
{
p->next = p2;
p1->next = p2->next;
p2->next = p1;
}
p = p->next;
}
}
return L;
}
void print_list(List_<int> list)
{
cout << setw(10);
for (int i = 1; i <= list.size(); i++)
cout << setw(10) << list.get(i)->data;
cout << endl << setw(10) << "address:";
for (int i = 1; i <= list.size(); i++)
cout << setw(10) << list.get(i);
cout << endl << setw(10) << "next:";
for (int i = 1; i <= list.size(); i++)
cout << setw(10) << list.get(i)->next;
cout << endl << setw(10) << "pre:";
for (int i = 1; i <= list.size(); i++)
cout << setw(10) << list.get(i)->pre;
}
void path(vector<int> & l, stack<int> & p, int i)
{
if (i >= l.size()/* || l[i] == -1*/ )
{
printStack(p);
p.pop();
}
else
p.push(l[i]);
path(l, p, i * 2);
path(l, p, i * 2 + 1);
}
int main()
{
undirectedGragh<int> g;
//g.create();
system("pause");
}