CPP新类型数组
1 /* CPP新类型数组 */
2
3 #include<iostream>
4 #include<array>
5 #include<string>
6 #include<stdlib.h>
7
8 void main()
9 {
10 double db[4] = {1.1,2.2,3.3,4.4};
11
12 // std::array 数组的数据类型 double:元素类型 4 个数
13 std::array<double,4> dbnew1 = {10.1,10.2,10.3,10.4};
14 std::array<double,4> dbnew2 = dbnew1;// 可以实现数组之间的整体操作
15 for (int i=0; i<4; i++)
16 {
17 std::cout << db[i] << " " << dbnew1[i]<<" " << dbnew2[i] << std::endl;
18 }
19
20 std::cin.get();
21 }
22
23 //-----------------------------------------------
24
25 void main()
26 {
27 std::array<std::string,5> string1 = {"calc","notepad","tasklist","mspaint","write"};
28
29 for (int i=0; i<5; i++)
30 {
31 std::cout << string1[i] << std::endl;
32 system(string1[i].c_str());
33 }
34
35 std::cin.get();
36 }
37
38 //-----------------------------------------------
39
40 void main()
41 {
42 std::string str1 = "task";
43 std::string str2 = "list";
44 std::string str3 = str1+str2;
45 system(str3.c_str());
46 std::cin.get();
47 }
长风破浪会有时,直挂云帆济沧海
posted on 2015-05-31 17:13 Dragon-wuxl 阅读(472) 评论(0) 收藏 举报
浙公网安备 33010602011771号