摘要: 3.31 1 #include <iostream> 2 #include <vector> 3 #include <string> 4 using namespace std; 5 int main() 6 { 7 constexpr int cnt = 10; 8 int ia[cnt]; 9 阅读全文
posted @ 2018-09-07 21:26 archerzon 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 使用一下方法遍历较简单,且输出是占一行: 比起下面简单得多,下面输出是一个数字一行: 阅读全文
posted @ 2018-09-07 20:55 archerzon 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 下标运算符[] 阅读全文
posted @ 2018-09-07 20:51 archerzon 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 内置类型是编程语言自己定义的一些类型在C++中内置类型有:整型:①整数 int、short和long②字符型 char和wchar_t③布尔型 bool整型可用修饰:unsigned浮点:float、double和long double 重点:string不是内置类型,其放在std标准库中。所以st 阅读全文
posted @ 2018-09-07 20:10 archerzon 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 确实是一种类型,所谓 size_type 就是这个“vector 的 size 的类型”。 size就是指vector有多少个元素,这个“多少个”也是个整型值,它的类型就是 size_type。 举个具体的例子: 假如有个vector,你调用size()来得到它有多少个元素,你要把这个值存在一个变量 阅读全文
posted @ 2018-09-07 14:55 archerzon 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 迭代器(iterator) P96:使用迭代器将字符串中的每个元素变成大写: 1 #include <iostream> 2 #include <vector> 3 #include <string> 4 #include <typeinfo> 5 using namespace std; 6 in 阅读全文
posted @ 2018-09-07 14:54 archerzon 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 3.16 1 #include <iostream> 2 #include <vector> 3 #include <string> 4 using namespace std; 5 using std::string; 6 int main() 7 { 8 vector<int> v1; 9 /* 阅读全文
posted @ 2018-09-07 11:02 archerzon 阅读(198) 评论(0) 推荐(0) 编辑