Repository navigation
Expand file tree
/
Copy patherr.txt
More file actions
323 lines (264 loc) · 5.68 KB
/
Copy patherr.txt
File metadata and controls
323 lines (264 loc) · 5.68 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
//001
#include <iostream>
using namespace std;
int main() {
// insert code here...
int i = 1;
cout << "欢迎" << endl;
cout << 'a' << endl;
cout << "i=" << i << end1;
cout << '\n';
return 0;
}
//002
#include <iostream>
#include <climits>
#include <cfloat>
using namespace std;
int main()
{
int iA;
short sB;
long lK;
float fC;
double dj;
long double kk;
cout << "i:(" << INT_MIN << "," << INT_MAX << ")" << endl;
cout << "j:(" << SHRT_MIN << "," << SHRT_MAX << ")" << endl;
cout << "k:(" << L0NG_MIN << "," << LONG_MAX << ")" << endl;
cout << "ii:(" << FLT_MIN << "," << FLT_MAX << ")" << endl;
cout << "jj:(" << DBL_MIN << "," << DBL_MAX << ")" << endl;
cout << "kk:(" << LDBL_MIN << "," << LONG_MAX << ") << endl;
return 0;
}
//003
#include <iostream.h>
using namespace std;
int main()
{
int iNumberA = 3;
int iNumberB = 5;
cout << "iNumberA = " << iNumberA << endl;
cout << "iNumberB = " << iNumberB << endl;
cout << "double所占的字节数:" << sizeof(double) << endl;
cout << "long double所占的字节数:" << sizeof(longdouble) << endl;
return 0;
}
//004 交换变量
#include <iostream>
using namespace std;
int main()
{
int iA = 5;
int iB = 8;
int iTemp; //iTemp 起一个缓冲性作用,用于临时放置交换变量的其中一方
cout << "交换前的值:iA = " << iA << " iB = " << iB << endl;
iTemp = iA;
iA = iB
iB = iTemp;
cout << "交换后的值:iA = " << iA << " iB = " << iB << endl;
return 0;
}
//005 交换变量
#include <iostream>
using namespace std;
int main()
{
int iA = 5;
float iB = 8.0001;
int iSum; //iTemp 起一个缓冲性作用,用于临时放置交换变量的其中一方
iSum = iA + iB;
cout << "iSum = " << iSum << endl; //隐式类型转换
cout << "iA + iB = " << iA + iB << endl; //13.0001 6位
return 0;
}
//006
#include <iostream>
using namespace std;
int main()
{
int iPoolVolume = 0;
int iCount = 3;
while (iCount != 0)
{
cin >> iPoolVolume;
if (iPoolVolume > 100)
{
cout << "泳池水已满,停止加水或者加入另一个游泳池" <<endl;
}
else
{
cout << "可继续加水" << endl;
}
iCount--;
}
return 0;
}
}
//007 显式类型转换
#include <iostream>
using namespace std;
int main()
{
int iNum = 2;
float fNum = 3.154;
iNum = (int)fNum;
cout << "显式类型转换,赋值后的iNum值为:" << iNum << endl;
}
//008 单片机应用
#include <iostream>
using namespace std;
int main()
{
int iNumA = 10;
int iNumB = 2;
int iNumC = 0;
iNumC = iNumA & iNumB;
cout << "iNumA & iNumB 的结果是:" << iNumC << endl;
iNumC = iNumA | iNumB;
cout << "iNumA | iNumB 的结果是:" << iNumC << endl;
iNumC = iNumA ^ iNumB;
cout << "iNumA ^ iNumB 的结果是:" << iNumC << endl;
iNumC = ~iNumA;
cout << "~iNumA 的结果是:" << ~iNumC << endl;
iNumC = iNumA << 1;
cout << "iNumA << 1 的结果是:" << iNumC << endl;
iNumC = iNumA >> 1;
cout << "iNumA >> 1 的结果是:" << iNumC << endl;
return 0;
}
//0011 取余数
#include <iostream>
using namespace std;
int main()
{
int iAppleNumber = 60;
int iPeopleNumber = 7;
int iPeopleRemainNumber = 0;
if (iPeopleNumber == 0)
{
iPeopleRemainNumber = iAppleNumber % iPeopleNumber;
cout << "剩余的苹果数是:" << iPeopleRemainNumber << endl;
}
else
{
cout << "除数不能为0" << endl;
}
return 0;
}
//013 称水果
#include <iostream>
using namespace std;
int main()
{
float fWeight = 0;
int iWeight = 0;
cout << "请输入水果的质量:" << endl;
cin >> fWeight;
float fWeightDecimal = fWeight - (int)fWeight;
if (fWeightDecimal > 0.5)
{
iWeight = (int)(fWeight - fWeightDecimal + 1);
}
else
{
iWeight = (int)(fWeight - fWeightDecimal);
}
cout << "称的水果质量是:" << iWeight << endl;
return 0;
}
//014 简单算术
#include <iostream>
#include "Sales_item.h"
using namespace std;
//自定义函数,给优先级人为返回序号,方便后面的排序
int level(Char ch)
{
switch (ch)
{
case '!':
return 2;
break;
case '*':
return 3;
break;
case '/':
return 3;
break;
case '%':
return 3;
break;
case '+':
return 4;
break;
case '-':
return 4;
break;
case '=':
return 5;
break;
default:
return -1;
break;
}
}
int main()
{
char symbol[3];
int value[3];
cout << "从!、*、/、%、+、-、= 运算符中选择 3 个参与算术运算" << endl;
cin >> symbol[0] >> symbol[1] >> symbol[2];
value[0] = level(symbol[0]);
value[1] = level(symbol[1]);
value[2] = level(symbol[2]);
if ((value[0] = -1) || (value[1] = -1) || (value[2] = -1))
{
cout << "库中没有输入的运算符" << endl;
}
else
{
for (int i = 0; i < 3; i++)
{
for (int j = i ; j < 3; j++)
{
if (value[i] > value[j])
{
char temp;
temp = symbol[i];
symbol[i] = symbol[j];
symbol[j] = temp;
}
}
}
cout << "依次进入运算的顺序为:" << endl;
for (int k = 0; k < 3; k++)
{
cout << symbol[k] << endl;
}
}
return 0;
}
//016 计算年份是否为闰年
#include <iostream>
using namespace std;
int main()
{
int year = 0;
cin >> year;
if ( (year % 400) = 0 )
{
cout << "输入的年数为闰年" << endl;
return 0;
}
else if ( (year % 4) = 0 && (year % 100) != 0)
{
cout << "输入的年数为闰年" << endl;
return 0;
}
cout << "输入的年数不为闰年" << endl;
return 0;
}
//
————————————————
版权声明:本文为CSDN博主「fizzwang」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/CV2017/article/details/82597666