上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页
摘要: 1. bitset<10> a;//a有10位,每位是0 bitset<10> a1(a);//a1是a的一个副本 bitset<16> b(0xffff);//b有16位,每位是1 bitset<32> c(0xffff);//c有16位,0-15是1,16-31是0 //初始化长度超过bitse 阅读全文
posted @ 2020-05-16 12:50 幻想Elapse 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1. 容器的bengin()指代第一个元素,end()不指向任何元素,只起哨兵作用,表示已经处理完vector中的所有元素 iterator解引用:*it 2. iterator的自增:向前移动 由于end()不指向任何元素,不能对其使用解引用或者自增操作 3. 用iterator遍历vector 阅读全文
posted @ 2020-05-08 15:54 幻想Elapse 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1. vector初始化: s2为s1副本: n个相同元素: 值初始化: 用一个由库生成的初始值初始化元素,具体值取决于元素类型 可见string类型是初始化为空串,int类型初始化为0 显然:空间在初始化时已经申请 2. 二维vector:> >有空格 s含三个元素,每个元素是大小为4的vecto 阅读全文
posted @ 2020-05-08 12:41 幻想Elapse 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1. string类型初始化: string s3;//s3为空串 2.getline() getline(string,n); 开头不忽略换行符,不忽略空格,而cin会,返回时忽略换行符 。 3. s.size() 算上空格 4. s.empty(); 5. size == 0 ->empty() 阅读全文
posted @ 2020-05-07 20:31 幻想Elapse 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1. 声明:extern i; 2. 将循环边界用一个变量标志,方便修改,使用const限定符, const int buf_size = 100; 3. const定义的变量默认是局部变量,不能被其他文件访问, 如有需要,extern const int i; 非const 变量默认为extern 阅读全文
posted @ 2020-05-07 19:07 幻想Elapse 阅读(534) 评论(0) 推荐(0) 编辑
摘要: 1.多项式为0,直接输出0 2.系数为0的项不输出 3.注意double类型的判0 1 #include <iostream> 2 #include <vector> 3 #include <iomanip> 4 #include <cmath> 5 using namespace std; 6 7 阅读全文
posted @ 2020-05-06 09:56 幻想Elapse 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 思路: 1.如果是负的先输出'-',再转换为正数。 2.如果是0,直接输出。 3.以999991为例,先%10,得1,将1存入容器,总数-1(为999990);再%100,得90,除以(100/10),得9,将9存入容器,总数-90(为999900);再%1000,得900,除以(1000/10)得 阅读全文
posted @ 2020-05-05 17:15 幻想Elapse 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 int main() 6 { 7 int N; 8 cin >> N; 9 vector<int> s1, s2, s3; 10 for (int i = 0; 阅读全文
posted @ 2020-05-04 17:43 幻想Elapse 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 最后一个测试点超时 1 #include <iostream> 2 #include <vector> 3 #include <string> 4 using namespace std; 5 int main() 6 { 7 vector<int>l1, l2, l3; 8 while (1) 9 阅读全文
posted @ 2020-05-04 17:11 幻想Elapse 阅读(516) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 using namespace std; 3 typedef struct node 4 { 5 int id; 6 struct node* next; 7 }*L; 8 int main() 9 { 10 L l1=NULL, l2=NULL, l 阅读全文
posted @ 2020-05-04 16:07 幻想Elapse 阅读(428) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页