栈
0.1
数据结构_第3章
ch3_3.cc
Go to the documentation of this file.
1
12
#include "
Permute.hh
"
13
14
int
main
(
int
argc,
char
const
*argv[])
15
{
16
// time
17
time_t rawtime;
18
struct
tm *timeinfo;
19
20
time(&rawtime);
// Get the current calendar time
21
timeinfo = localtime(&rawtime);
// Convert time_t to tm as local time
22
printf(
"Current local time and date: %s\n"
, asctime(timeinfo));
// Convert tm structure to string
23
24
clock_t t;
25
26
if
(argc > 1)
27
{
28
// std::cout << "\nNon-recursive permute(STL):\n";
29
// ch3_3::permute_stl(std::string(argv[1]));
30
31
std::cout <<
"Recursive permute:\n"
;
32
t = clock();
33
ch3_3::permute_rec
(std::string(argv[1]));
34
t = clock() - t;
35
printf(
"permute_rec(%s) took %ld clicks (%f seconds).\n"
, argv[1], t, ((
float
)t) / CLOCKS_PER_SEC);
36
37
std::cout <<
"\nNon-recursive permute(Stack):\n"
;
38
t = clock();
39
ch3_3::permute_loop
(std::string(argv[1]));
40
t = clock() - t;
41
printf(
"permute_loop(%s) took %ld clicks (%f seconds).\n"
, argv[1], t, ((
float
)t) / CLOCKS_PER_SEC);
42
43
return
0;
44
}
45
46
std::string str;
47
do
48
{
49
std::cout <<
"\nPlease input a string: "
;
50
std::cin >> str;
51
if
(!std::cin.fail())
52
break
;
53
54
std::cin.clear();
55
std::cin.sync();
56
}
while
(
true
);
57
58
std::cout <<
"\nNon-recursive permute(STL):\n"
;
59
t = clock();
60
ch3_3::permute_stl
(str);
61
t = clock() - t;
62
printf(
"permute_stl(%s) took %ld clicks (%f seconds).\n"
, str.c_str(), t, ((
float
)t) / CLOCKS_PER_SEC);
63
64
std::cout <<
"Recursive permute:\n"
;
65
t = clock();
66
ch3_3::permute_rec
(str);
67
t = clock() - t;
68
printf(
"permute_rec(%s) took %ld clicks (%f seconds).\n"
, str.c_str(), t, ((
float
)t) / CLOCKS_PER_SEC);
69
70
std::cout <<
"\nNon-recursive permute(Stack):\n"
;
71
t = clock();
72
ch3_3::permute_loop
(str);
73
t = clock() - t;
74
printf(
"permute_loop(%s) took %ld clicks (%f seconds).\n"
, str.c_str(), t, ((
float
)t) / CLOCKS_PER_SEC);
75
76
return
0;
77
}
ch3_3::permute_loop
void permute_loop(const T &_s)
Definition:
Permute.hh:197
main
int main(int argc, char const *argv[])
Definition:
ch3_3.cc:14
Permute.hh
全排列
ch3_3::permute_rec
void permute_rec(const T &_s)
Definition:
Permute.hh:186
ch3_3::permute_stl
void permute_stl(const T &_s)
Definition:
Permute.hh:241
src
ch3_3.cc
Generated on Mon Jul 6 2020 21:04:43 for 栈 by
1.8.17