上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 68 下一页
摘要: max_element()函数和min_element()函数,我们从函数名字就能知道是什么作用了,就是找最大值最小值,那怎么用呢? 数组:int position=max_element(a,a+n)-a; int data=*max_element(a,a+n); 容器: int positio 阅读全文
posted @ 2020-06-08 19:41 立体风 阅读(2091) 评论(0) 推荐(0)
摘要: 一些关键概念在我们揭开真实原因的面纱之前,先保持一点神秘感,因为为了更好的理解C++标准,有几个重要的概念需要先行介绍一下。 限定名和非限定名限定名(qualified name),故名思义,是限定了命名空间的名称。看下面这段代码,cout和endl就是限定名: #include <iostream 阅读全文
posted @ 2020-06-04 13:04 立体风 阅读(1623) 评论(0) 推荐(1)
摘要: 如果list作为常量参数传入函数时,使用list的迭代器要注意,如果代码这样写: ostream& operator<<(ostream& ostr,const list<int>& li){ list<int>::iterator it=li.begin(); while(it!=li.end() 阅读全文
posted @ 2020-05-26 06:59 立体风 阅读(773) 评论(0) 推荐(0)
摘要: C++ STL 中list是双向循环链表,双向可以理解,有两个指针域,指向前一结点和指向后一结点,双向可以实现从末尾结点到头结点的遍历,但循环实现什么功能? 错误代码: #include<list> #include<iostream> int main() { list<int> li; for( 阅读全文
posted @ 2020-05-26 05:54 立体风 阅读(2198) 评论(0) 推荐(1)
摘要: 典型错误 for(list::iterator it=li.begin();it!=li.end();it++){ li.erase(it); } 问题:该程序不能跳出循环原因:li.erase(it);每次做erase时都有可能使迭代器失效,it++就发生错误了。可以参见effective stl 阅读全文
posted @ 2020-05-25 20:16 立体风 阅读(3272) 评论(0) 推荐(2)
摘要: lime^x,也就是当x趋近于某一个值a时,e^x的值也就趋近e^a, 含义也就为lime^x=lime^limx=lime^a,此时与x无关,lime^a=e^a; e^limx,当x趋近于某一个值a时,e^limx=e^a。所以lime^x=e^limx 阅读全文
posted @ 2020-03-18 22:27 立体风 阅读(2527) 评论(0) 推荐(0)
摘要: 如果不想首段缩进,只需在导言区添加: \usepackage{parskip} \setlength{\parindent}{0cm} Latex默认纸张大小和标准A4纸有出入,并且其默认的边距margin不适合标准A4纸的阅读。 解决办法: 使用如下两句定义A4页面大小和边距: \document 阅读全文
posted @ 2020-03-11 20:32 立体风 阅读(1937) 评论(0) 推荐(0)
摘要: 多行公式输入,还有一个对齐的问题,通常多行且左对齐,用&和\\两个符号搞定,看代码: \begin{align} & \left[x + \frac{-\sqrt{5} + 1}{2}\right] \; \left(x + \frac{\sqrt{5} + 1}{2} \right) \\ & \ 阅读全文
posted @ 2020-02-27 09:59 立体风 阅读(6824) 评论(0) 推荐(0)
摘要: c语言中没有类似substr截取子串的函数,可以用strncpy,strncat实现 #include<cstdio> #include<cstring> using namespace std; int main(){ char a[20]="helloworld"; char b[20]=""; 阅读全文
posted @ 2020-02-23 11:56 立体风 阅读(4326) 评论(0) 推荐(0)
摘要: 指针变量有3个值,自己的地址,保存的地址和保存地址内的值 #include <cstdio> int main(){ int a=10; int *p=&a; printf("p的地址:%p\n",&p); printf("p保存的地址:%p\n",p); printf("p保存地址内的值:%d\n 阅读全文
posted @ 2020-02-23 10:37 立体风 阅读(389) 评论(0) 推荐(0)
上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 68 下一页