c语言编译如何表示无输出,C语言模拟数组时遇到的问题,编译无误,但无输出

# include

# include

void inint(struct Arrylist *,int);//

bool add(struct Arrylist *, int, int);//

bool del(struct Arrylist *, int, int);

bool reverse(struct Arrylist *);

bool show(struct Arrylist *);//

bool is_empty(struct Arrylist *);//

bool is_full(struct Arrylist *);//

bool append(struct Arrylist *, int);

struct Arrylist

{

int * p;//the address of the first element of the arrylist

int con;//the real element number of the arrylist

int len;//the max of the length of the arrylist

};

int main(void)

{

struct Arrylist * ay;

inint(ay, 6);

append(ay, 1);

append(ay, 2);

append(ay, 3);

show(ay);

return 0;

}

bool is_full(struct Arrylist * arry)//judge a arry is full or not

{

if(arry->con == arry->len)

{

return true;

}

else

{

return false;

}

}

bool show(struct Arrylist * arry)// to show the arry

{

if( is_empty(arry) )

{

printf("The arrylist is empty!\n");

return false;

}

for(int i = 0; i < arry->con-1; i++)

{

printf("show the arry :%d", (arry->p)[i]);

}

return true;

}

void inint(struct Arrylist * arry, int len)//inintilization the arry

{

arry->p = (int *)malloc(sizeof(int)*len);

arry->con = 0;

arry->len=len;

return;

}

bool append(struct Arrylist * arry, int val)

{

if( is_full(arry) )

{

printf("the arry is full!\n");

return false;

}

arry->p[arry->con-1] = val;

arry->con++;

return true;

}

bool is_empty(struct Arrylist * arry)//judege whether a arry is empty or not

{

if(arry->con == 0)

{

return true;

}

else

{

return false;

}

}

bool add(struct Arrylist * arry, int pos, int val)//add element

{

if(is_full(arry))

{

printf("Arrylist is full!");

return false;

}

else if(pos < 1 || pos > arry->con+1)

{

printf("Wrong add!");

return false;

}

else

{

for(int i = arry->con; i > pos; i--)

{

(arry->p)[i-1] = (arry->p)[i-2];

}

(arry->p)[pos-1] = val;

arry->con++;

return true;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值