33,311
社区成员
发帖
与我相关
我的任务
分享
typedef struct SqList
{
ElemType *elem; // 存储空间基址
int length; // 当前长度
int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)
}SqList;
int InitList(SqList& L) /*这一行提示错误*/
{ // 操作结果:构造一个空的顺序线性表---------------1
L.elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L.elem)
// exit(OVERFLOW); // 存储分配失败
L.length=0; // 空表长度为0
L.listsize=LIST_INIT_SIZE; // 初始存储容量
return 1;
}
#include <string.h>
#include <ctype.h>
#include <malloc.h>//malloc
#include <limits.h>//int_max
#include <stdio.h>//EOF
#include <stdlib.h>//atoi
#include <io.h>
#include <math.h> // floor(),ceil(),abs()
#include <process.h> // exit()
#include <iostream.h> // cout,cin
// 函数结果状态代码
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2 因为在math.h中已定义OVERFLOW的值为3,故去掉此行
typedef int Status; // Status是函数的类型,其值是函数结果状态代码,如OK等
typedef int Boolean; // Boolean是布尔类型,其值是TRUE或FALSE
typedef int ElemType;
#define LIST_INIT_SIZE 10 // 线性表存储空间的初始分配量
#define LISTINCREMENT 2 // 线性表存储空间的分配增量
typedef struct SqList
{
ElemType *elem; // 存储空间基址
int length; // 当前长度
int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)
}SqList;
#include "maopao.h"
#include <time.h> //时间获取头文件
/*
************************************
*main函数,加入了记时,以便确定程序运行的时间特性
************************************
*/
int main(int argc, char *argv[])
{
clock_t a,b;
double time;
a=clock();
b=clock();
time=(double)(b-a)/CLOCKS_PER_SEC;
//b-a表示程序运行了多少个时钟单元,常量表示每秒有多少个时钟单元,相除即表示b和a之间有多少秒。
printf("The time was: %f seconds\n", time);
return 0;
}
Status InitList(SqList& L)
{ // 操作结果:构造一个空的顺序线性表---------------1
L.elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L.elem)
exit(OVERFLOW); // 存储分配失败
L.length=0; // 空表长度为0
L.listsize=LIST_INIT_SIZE; // 初始存储容量
return OK;
}
#define LIST_INIT_SIZE 10
using namespace std;
typedef char ElemType;
typedef struct SqList_l
{
ElemType *elem; // 存储空间基址
int length; // 当前长度
int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)
}SqList;
int InitList(SqList& L) /*这一行提示错误*/
{ // 操作结果:构造一个空的顺序线性表---------------1
L.elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L.elem)
// exit(OVERFLOW); // 存储分配失败
L.length=0; // 空表长度为0
L.listsize=LIST_INIT_SIZE; // 初始存储容量
return 1;
}
void main()
{
int i;
SqList l;
i=InitList(l);
}