-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
220 lines (168 loc) · 3.43 KB
/
main.cpp
File metadata and controls
220 lines (168 loc) · 3.43 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include <iostream>
#include "stringStudy.h"
#include "vectorStudy.h"
#include "securityFun.h"
#include "useOfArray.h"
//#include "referenceTest.h"
#include "arithmeticOperate.h"
#include "TypeConversion.h"
#include "Function.h"
#include "sudoku.h"
#include "memoryAlign.h"
#include "AlgorithmOfSTL.h"
#include "ControlFlow.h"
//header shouldnot include using declaration
using namespace std;
//The assert macro is often used to check for conditions that “cannot happen.”
/*
typedef的使用
*/
typedef double wage;
typedef wage base, *p;//base is double p is *double;
using type_double = double;//type_double is double
int global_i = 1;
int main()
{
const int &n1 = 1;
const auto &n2 = 1;
int &&n = 1;
//int &n = 1;
int i = 1;
// reference must be initialized
//int &rr;
int &r = i;
int *p1 = &i;
cout << *p1 << endl;
int *p2 = &r;
cout << *p2 << endl;
cout << &i << " " << p1 << " " << &r << endl;
//int &r1 = 3;
/*
vs2013中不支持 constexpr
详情参阅
http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx
*/
//constexpr int conexpr = 2;
//constexpr int *const_p = &global_i;// constexpr如果修饰的是指针则指针本身的地址为const,注意右值的地址必须为fixed。
//const int *p = nullptr;// p is a pointer to a const int
//constexpr int *q = nullptr; // q is a const pointer to int
//int null = 0, *p_null = null;
//cout << "testReference!" << endl;
/*
string test!
*/
//sizeAndLength();
//NormalUseOfString();
//UseOfGetLine();
//newFor();
//useOfc_strString();
/*
string test!
*/
/*
vector test!
*/
//normaluseOfVector();
//useOfremove_if();
//initializeOfVector();
/*
vector test!
*/
/*
security function
*/
//cout << "use of strcpy_s()" << endl;
//useOfstrcpy_s();
/*
security function
*/
/*
array
*/
//cout << "test array" << endl;
//copyOrAssignmentOfArray();
//beginAndendFunc();
/*
array
*/
/*
arithmeticOperate
*/
//normalArithmetic();
//wrappedaround();
//useOfRelationalOperator();
/*
arithmeticOperate
*/
/*
typeconversion
*/
//useOfconst_cast();
//useOfNullStatement();
/*
typeconversion
*/
/*
function
*/
//useOfinitializer_list({ "fsdfsfsdf", "sdfsdfsfddsf", "helloworld" });
//vector<int> vec1 = { 1, 2, 3, 4, 5 };
//useOfvectorPara(vec1);
//for (auto e:vec1)
//{
//cout << e << endl;
//}
/*
function
*/
/*
sudoku
*/
/*
vector<vector<int> > s = {
{ 2, 7, 6, 0, 0, 0, 0, 8, 0 },
{ 3, 0, 0, 8, 0, 0, 0, 1, 5 },
{ 5, 0, 0, 2, 0, 9, 7, 0, 0 },
{ 0, 8, 2, 3, 0, 0, 4, 0, 0 },
{ 0, 0, 0, 0, 5, 0, 0, 0, 0 },
{ 0, 0, 1, 0, 0, 4, 3, 6, 0 },
{ 0, 0, 4, 5, 0, 8, 0, 0, 7 },
{ 1, 6, 0, 0, 0, 3, 0, 0, 4 },
{ 0, 3, 0, 0, 0, 0, 5, 2, 1 }
};
*/
vector<vector<int> > s1 = {
{ 8, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 3, 6, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 9, 0, 2, 0, 0 },
{ 0, 5, 0, 0, 0, 7, 0, 0, 0 },
{ 0, 0, 0, 0, 4, 5, 7, 0, 0 },
{ 0, 0, 0, 1, 0, 0, 0, 3, 0 },
{ 0, 0, 1, 0, 0, 0, 0, 6, 8 },
{ 0, 0, 8, 5, 0, 0, 0, 1, 0 },
{ 0, 9, 0, 0, 0, 0, 4, 0, 0 }
};
//useOfcomplicatedVectorPara(s);
//printOfcomplicatedVectorPara(s);
//sudoku solution;
//solution.printSolution(s);
//solution.getSolution(s1);
//cout << "the solution is" << endl;
//solution.printSolution();
/*
memoryAlign
*/
//testMemoryPos();
/*
memoryAlign
*/
/*AlgorithmOfSTL*/
//testOfInsertIterator();
useOfElseif();
auto f = [](){cout << "this is fun" << endl; };//lambda
f();
int wait;
cout << "input any key to exit!" << endl;
cin >> wait;
return 0;
}