数据结构
文章平均质量分 86
cdgdd
Every day may not be good,but there's something good in every day.
展开
-
一道面试题
不要认为CPU运算速度快就把所有的问题都推给它去做,程序员应该将代码优化再优化,我们自己能做的决不要让CPU做,因为CPU是为用户服务的,不是为我们程序员服务的! 面试题目:写一个函数计算当参数为n(n很大)时的值 1-2+3-4+5-6+7......+n 一位面试者给出了如下代码: long fn(long n) { long temp=0; int i,fla翻译 2012-07-10 12:56:22 · 374 阅读 · 0 评论 -
C++实现线性表的操作
#include #include typedef int ElemType; struct List { ElemType *list; //存线性表元素的动态存储空间的指针 int size; //存线性表长度 int MaxSize; //规定list数组的长度 }; //初始化L为空 void InitList(List &L) { L.MaxSize=10; //初始原创 2012-07-11 10:51:32 · 1270 阅读 · 0 评论 -
C++实现单链表操作
#include #include typedef int ElemType; //规定元素类型为整型 //定义单链表结点 struct LNode { ElemType data; LNode* next; }; //初始化单链表 void InitList(LNode* &HL) { HL=NULL; //置单链表为空 } //清空单链表 void ClearList(LNode原创 2012-07-11 11:00:00 · 558 阅读 · 0 评论