
网络合作学习
iamlijiangtao
这个作者很懒,什么都没留下…
展开
-
关于链表的方法——伟民
#include #include #include #include typedef int elemtype;typedef struct linknode{ elemtype data; struct linknode *next;}nodetype;//---------------create a link list?NO, create a no原创 2009-10-10 10:03:00 · 1085 阅读 · 0 评论 -
if (infile.good())//==============当被注释掉会多输出两个空格。但存在时不输出最后的两个空格,为什么??
#include #include using namespace std;int main () { char c, str[256]; ifstream is; cout << "Enter the name of an existing text file: "; cin.get (str,256); is.open (str);原创 2009-11-09 15:48:00 · 1269 阅读 · 0 评论 -
对一个简单递归的 时间复杂度的分析
#include using namespace std;/************************************************************************//* 算法说明:本文算法来自,数据结构考研试题分析算法意义:编写递归算法,并分析时间复杂度 *//********原创 2009-11-02 22:21:00 · 1103 阅读 · 0 评论 -
判断回文 字符串的最后一个字符是'/0', 而不是'/n' ,基础知识都忘了
#include #include using namespace std;template BOOL cycle(elem* begin, elem* end){ while(begin <=end) { if (*begin!=*end) return FALSE; begin++; end--; } return TRUE;原创 2009-11-08 22:05:00 · 784 阅读 · 0 评论 -
cout<<字符数组 getline(流,string,delimit character) 遇到的问题
#include #include using namespace std;#include void main(){ cout<<"please input two line string : "<<endl;/* string str=NULL;//--used to store a string //============must be initialize.原创 2009-11-09 15:32:00 · 805 阅读 · 0 评论 -
infile.getline() infile.get() 出现的问题,还没有解决.换成 getline(infile,str) 就正常了。所以用高级类型更安全,以后应该用高级类型string等
#include #include using namespace std;#include void main(){ ifstream infile; infile.open("data.txt",ios::in); if (!infile) cerr<<"open the file fail."<<endl; if (!infile.is_open原创 2009-11-09 16:33:00 · 2478 阅读 · 0 评论 -
infile.getline() infile.get() 出现的问题,还没有解决
#include #include using namespace std;//命名空间#include void main(){ ifstream infile; infile.open("data.txt",ios::in);//打开文件,以便后边读取内容 if (!infile)/*检查文件是否打开*/ cerr<<"open the原创 2009-11-09 15:37:00 · 6263 阅读 · 2 评论 -
对于网上合作学习计划的整理
对于网上合作学习计划的整理摘自:靳雄飞的博客 目录: 读S计划介绍... 3读S计划的理念... 3读S计划的初衷... 3读S计划的独特之处:... 3学习计划的实施细则... 4目前的技术手段汇总(项目网址,入口)... 4所谓“参与”学习... 4欢迎申请做KO,KE. 5关于队伍凝聚力和学习方向的一点建议... 5组织结构原创 2009-11-14 09:24:00 · 990 阅读 · 0 评论 -
biTree 大数插入右子树,小数插入左子树,子函数create , insert
#include using namespace std;//--------------biTree node struct----------struct tree{ struct tree * left; int data; struct tree * right;};typedef struct tree treeNode;//-------- de原创 2009-11-16 20:17:00 · 582 阅读 · 0 评论 -
全局变量 静态全局变量 静态局部变量 局部变量
//------全局变量 静态全局变量-----------/*静态全局变量 全局变量就是 外部变量。外部变量就是全局变量。不管你定义在哪个文件中。所谓全局就是可以扩展其作用范围到其他文件。 而静态全局变量就不能扩展作用域到其他文件。 静态局部 与 局部变量 静态局部在多次调用他所在的函数时,不重新分配内存--保存其值,而局部变量重原创 2009-11-19 20:16:00 · 576 阅读 · 0 评论 -
插入排序
#include #include using namespace std;//----------compare ------------templateBOOL larger(elemtype b, elemtype a){ if (b>a) { return TRUE; } else //-------华为编程规范: 哪怕语句块只有一条语句也原创 2009-11-20 08:42:00 · 398 阅读 · 0 评论 -
二叉树 create addnew
#include using namespace std;//--------------biTree node struct----------struct tree{ struct tree * left; int data; struct tree * right;};typedef struct tree treeNode;//-------- de原创 2009-11-20 08:44:00 · 377 阅读 · 0 评论 -
测试 static 局部变量 与 局部变量的不同
/*测试: static 局部变量 与 局部变量的不同 执行结果:-->the 0th invoke the function func()accountStaticLocal = 1accountLocal = 1-->the 1th invoke the function func()accountStaticLocal = 2account原创 2009-11-26 18:53:00 · 449 阅读 · 0 评论 -
一个错误的链表程序 ——编译通过,执行出错。自己没有好的调试技术,没有找到错误;而靠经验得逐行细查——费时间
// list.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include using namespace std;typedef struct node { int no;//-------应该用公用体,以便头节点用来存储节点个数 node*原创 2009-11-06 18:42:00 · 499 阅读 · 0 评论 -
用模板来 帮助子函数动态获得数组的长度
#include using namespace std;template display(int (&a)[arrayLength]){ for(int i=0;i< arrayLength;i++) cout<<" "a[i];}void main(){ int a[5]={0,1,2,3,4}; display(&a[]);}原创 2009-10-28 22:30:00 · 606 阅读 · 0 评论 -
二叉树 类
//biTreeNode class //==================================================================================//notation ://author :jiangtao//purpose: create a biTreeNode//=======================原创 2009-10-11 21:46:00 · 410 阅读 · 0 评论 -
折半插入排序算法
#include using namespace std;template void bInsertSort(elemtype *L,int length){ elemtype watcher; for(int i =1;i<length;i++) { watcher = L[i];// 放入岗哨 // 用折半查找法寻找擦汗如位置 int low原创 2009-10-14 21:52:00 · 1019 阅读 · 3 评论 -
插入排序
#include "stdafx.h"#include using namespace std;//对有序表做插入排序//注意序号【0】的数据职责是岗哨,不要存需要排序的数据void insertSort(int * list, int length){ for (int i=2;i<length;i++)//第一个元素为有序,然后后边依次插入 if(list[i原创 2009-10-12 22:12:00 · 350 阅读 · 3 评论 -
简单的数组查找算法 出现的错误:数组不可以使用引用传址
#include using namespace std;//--------------------针对数组的,简单的查找------------------/**/template int searchArray(elemtype *array, elemtype e,int length)// const 去保数据不被修改{ //计算数组长度 fo原创 2009-10-16 18:17:00 · 490 阅读 · 0 评论 -
shell sort 希尔排序问题
//==========================由于无法解决子序列的长度问题所以算法不正确,关键: 在子函数中求数组的长度#include "iostream"using namespace std;//---------------插入排序-------------------------templatevoid shellSort(elemtype *arr原创 2009-10-19 22:40:00 · 502 阅读 · 0 评论 -
多维数组当一维处理,并用数组模拟向量,来计算向量点积
#include using namespace std;//------------------把多维数组当成一位来看待。用一个数组元素类型的指针指向第三行元素地址,然后输出//------------------理论依据: 多维数组实际存储时 是一维的,连续存放的----------------------------//------------------计算向量点积,用数组原创 2009-10-21 21:27:00 · 1492 阅读 · 0 评论 -
文件读写
//--------------------读写文件,结构体为单位---------------#include #include using namespace std;typedef struct{ int num;// ---------the number of the point float x;// ---------the x coordi原创 2009-10-20 21:59:00 · 356 阅读 · 0 评论 -
当从文件读入数据时,注意文件最后一个换行符
这个是换行符,换行符的ascall码是13.问题是为什么文件前面的换行符并没有读入,而最后一个就读入了呢???代码如下include using namespace std;#include void main(){ char* filename ="parameters.txt";//输入数据的文件名 char* result ="result.txt";//输原创 2009-10-27 10:28:00 · 1562 阅读 · 0 评论 -
读取文件的重载符>是忽略 换行符的,而outfile.put(char), infile.get(char)不去忽略
#include using namespace std;#include //-------------- 测试打开文件夹中的文件是否正常,以前没有打开过文件夹中的文件,试试//void main(){ char* sourceFile ="cameraPoint/point2d.txt";//------------文件夹下的文件 char* objectFil原创 2009-10-28 22:41:00 · 2033 阅读 · 0 评论 -
制表符不是简单的八个字符,它的意思是光标跳到8的倍数处——最近的,8的倍数,的位置
#include using namespace std;void main(){ int i=0; cout<<"数据间隔一个制表符/t"<<endl; for (i=0;i<3;i++) { cout<<"/t"<<"我随便写的数据"; } cout<<endl;/************************************原创 2009-11-04 20:11:00 · 2101 阅读 · 0 评论 -
建立简单的链表 节点是结构体
#include using namespace std;#include #include //-----------------建立节点-------------typedef struct node { char* name; node* next;}NODE,HEAD;//-------------建立链表----------------原创 2009-10-27 22:34:00 · 1175 阅读 · 0 评论 -
关于多维数组做参数 的问题
#include using namespace std;//-----------------------多维数组作为参数-----------------------//-----------------------用多维数组多维形参,并输出数组-------//-------这种参数的定义格式算是重载,不与一下格式重读//-------错误:display原创 2009-10-28 21:46:00 · 840 阅读 · 0 评论 -
static 函数 不能为外部文件调用
测试 static 函数 的调用结果: 编译错误:error C2129: static function void __cdecl funcStatic(void) declared but not defined分析: 禁止外部文件调用 static 函数,仅仅 源文件中的函数可以调用static函数。否则出现上述编译错误。 #include原创 2009-11-26 20:01:00 · 3721 阅读 · 0 评论