小练习 没什么算法或者数据结构
#include <iostream>
namespace Fib
{
long Fib1(int n);
}
namespace Error
{
void ShowErr(int n);
}
long Fib::Fib1(int n)
{
int i;
long fib1=1,fib2=1,fib3=1;
if(n<=0||n>19)
 [......]
不定参数列表的小练习:-)
对于cstdarg宏用于不定参数列表不是很熟悉,做个小练习:-)
#include <iostream>
#include <cstdarg>
typedef int Elem;
using namespace std;
Elem MaxInt(int n,...)
{
va_list ap;
Elem max,tmp;
int i;
va_start(ap,n);
if(n<1)
&n[......]
《数据结构》读书笔记 第五章 数组的顺序存储实现
昨天读《The C++ Programing Language Special Edition》确实觉得注释是很重要的,所以今天开始所有程序都要练习注释,尽量写出好的注释来:-)
Array.h : 定义了数组的顺序存储的基本操作
#include <iostream>
#include <cstdarg>
typedef int Elem;
typedef int Status;
enum {WRONG=-1,OK=0};
struct Array
{
/*-[......]
《数据结构》读书笔记 第四章 文本编辑
文本编辑 有点BT啊……
#include <fstream>
#include "D:\数据结构\第四章 堆分配的串及其基本操作\HString.h"
enum {ML=25,MLL=75,MNL=20};
HString T[ML];
char str[MLL],filename[MNL]="";
int n=0;
using namespace std;
void Open()
{
[......]
《数据结构》读书笔记 第四章 堆分配存储串及基本操作
堆分配前天的普通串比有如下优点:
(1)节省空间,用多少,分配多少!
(2)struct结构体体积小,减少了位对齐的机会,提高了效率
缺点:
(1)用了new所以记得delete
(2)结构上字符串从0开始,这个下标是很折磨人的
HString.h
#include <iostream>
enum {OK=0,WRONG=-1};
typedef int Status;
struct HString
{
char *chars;
int len;
}[......]