-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (37 loc) · 914 Bytes
/
main.cpp
File metadata and controls
47 lines (37 loc) · 914 Bytes
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
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int main() {
// 数字定义
short s;
int i;
long l;
float f;
double d;
// 数字赋值
s = 10;
i = 1000;
l = 1000000;
f = 230.47;
d = 30949.374;
// 数字输出
cout << "short s :" << s << endl;
cout << "int i :" << i << endl;
cout << "long l :" << l << endl;
cout << "float f :" << f << endl;
cout << "double d :" << d << endl;
cout << "sizeof : " << sizeof(long) << endl;
cout << "abs(-10) :" << abs(-10) << endl;
cout << "-------------------------------------------" << endl;
// 设置种子
srand((unsigned) time(NULL));
/* 生成 10 个随机数 */
for (i = 0; i < 10; i++) {
// 生成实际的随机数
int j;
j = rand();
cout << "随机数: " << j << endl;
}
return 0;
}