C/C++
文章平均质量分 50
haida_liudan
codes make world clear
展开
-
c语言的static属性
一说到C的static属性首先想到隐藏,对于static变量值仅函数体内可见,对于static函数来说只有当前文件可见。对于变量,除了隐藏,static还有下面两个作用:保持变量内容的持久;默认初始化为0。存储在静态数据区的变量会在程序刚开始运行时就完成初始化,也是唯一的一次初始化。下面看个简单的测试程序: #include #define test_num 3 void test_sta原创 2013-03-30 09:51:54 · 689 阅读 · 0 评论 -
链表(c++实现)
用C++写了一个链表,虽然不难,但也没有想象中那么简单,况且代码质量也不够好。 直接看代码: list.h #include using namespace std; #ifndef LIST #define LIST typedef int ElemType; class List { public: List(); List(const List& other)原创 2013-04-12 18:57:59 · 509 阅读 · 0 评论 -
Dijkstra算法2:邻接表描述
邻接表是图的一种链式存储方式。对图的每个顶点建立一个单链表(n个顶点建立n个单链表),第i个单链表中的结点包含顶点Vi的所有邻接顶点。又称链接表。 邻接表的表示方法:1)表节点结构邻接表中每个表结点均有两个域:(还可加上与弧或者叫边相关的信息如:权值) ① 邻接点域adjvex 存放与vi相邻接的顶点vj的序号j。 ② 链域next 将邻接表的所有表结点链在一起。 2)头结点结构:原创 2013-04-17 20:32:46 · 1273 阅读 · 0 评论 -
系统级I/O健壮性读程序
取自深入理解计算机系统第十一章 #include #include #include #include #include #include #include #include #include /* rio with internal buf */ #define RIO_BUFSIZE 8192 typedef struct { int rio_fd; int ri原创 2013-05-16 22:19:39 · 723 阅读 · 0 评论 -
将一句话里的单词进行倒置,标点符号不倒换(c++)
实现一个函数将一句话里的单词进行倒置,标点符号不倒换。比如一句话“i come from wuhan.“倒置后变成"wuhan. from come i"。 #pragma warning (disable:4786) #include #include #include #include using namespace std; int main(void) { s原创 2013-08-20 11:11:06 · 2862 阅读 · 0 评论