1>按值进行修改函数
int listUpddatev(seqlist *S,datatype olde,datatype newe)
{
for(int i=0;i<S->len;i++)
{
if(S->data[i] == olde)
{
S->data[i] = newe;
}
}
printf ("%d修改为%d\n",olde,newe);
return 0;
}
2>按位置进行查找函数,返回查找到的数据
datatype listSearchp(seqlist *S,int pos)
{
if(listEmpty(S)||pos<0||pos>S->len-1)
{
printf("%d\n",S->len);
printf("查找失败\n");
return -1;
}
return S->data[pos];
}
3>使用选择排序实现顺序表降序
void listSelectsort(seqlist *S)
{
int i,j;
int index;
int temp;
for(i=0;i<S->len-1;i++)
{
index =i;
for(j=i+1;j<S->len;j++)
{
if(S->data[index]<S->data[j])
{
index =j;
}
}
if(index !=i)
{
temp =S->data[i];
S->data[i]=S->data[index];
S->data[index]=temp;
}
}
printf("排序后的结果为:\n");
listShow(S);
}