Technology Learning

导航

2009年9月25日

转:STL提供了三个最基本的容器:vector,list,deque。

摘要: vector和built-in数组类似,它拥有一段连续的内存空间,并且起始地址不变,因此它能非常好的支持随机存取,即[]操作符,但由于它的内存空间是连续的,所以在中间进行插入和删除会造成内存块的拷贝,另外,当该数组后的内存空间不够时,需要重新申请一块足够大的内存并进行内存的拷贝。这些都大大影响了vector的效率。 list就是数据结构中的双向链表(根据sgi stl源代码),因此它的内存空间可... 阅读全文

posted @ 2009-09-25 14:33 浔阳渔夫 阅读(1763) 评论(0) 推荐(0) 编辑

控制台输出问题

摘要: #include<iostream>using namespace std;int main(){char a[]={'h','e','l','\0'};cout<<a<<endl;return 0;}#include<iostream>using namespace std;int main(){int a[]={1,2,3};cout<&l... 阅读全文

posted @ 2009-09-25 09:13 浔阳渔夫 阅读(163) 评论(1) 推荐(0) 编辑

scanf 输出格式的问题!!!

摘要: #include <stdio.h>void main( void ){char c;int i;printf("input your choice:\n");scanf("%c",&c);while (c=='y'){printf( "\n\nEnter an int\n");scanf("%d",&i);printf("your input : %d\n",i);p... 阅读全文

posted @ 2009-09-25 09:02 浔阳渔夫 阅读(440) 评论(2) 推荐(0) 编辑