Demo entry 6645457

负数

   

Submitted by 杨阳 on Oct 10, 2017 at 13:28
Language: C. Code size: 240 Bytes.

//删除所有负数的函数
void delete_negative(list_type *lp)
{
	int j;
	for(j=0; j<lp->length;j++)//从顺序表头开始循环
	{
		if(lp->data[j]<0)//判断元素是否为负		
		{lp->data[j]=lp->data[j+1];//如果是,则后一位元素向前移一位
		j--;//从上一位元素开始重新判断
		lp->length--;}//元素长度减一
	}
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).