2/22作业

#include<stdio.h>
#include<string.h>

typedef struct
{
    char name[100];
    int high;
    double score;
}Stu,*Stu_p;
int main(int argc, const char *argv[])
{
    Stu arr[7]={{0}};
    for(int i=0;i<7;i++)
    {
        scanf("%s\n",arr[i].name);
        scanf("%d\n",&arr[i].high);
        scanf("%lf\n",&arr[i].score);
    }
    Stu temp;
    for(int i=1;i<=6;i++)
    {
        for(int j=0;j<7-i;j++)
        {
            if(arr[j].score>arr[j+1].score)
            {
            temp=arr[j];
            arr[j]=arr[j+1];
            arr[j+1]=temp;
            }
        }
    }
        for(int i=0;i<7;i++)
    {
        printf("%s %d %lf\n",arr[i].name,arr[i].high,arr[i].score);
    }
    return 0;
}
。。。。

void del(seq_p L)
{
        if(L==NULL)
    {
        return;
    }
    if(seq_empty(L))
    {
        printf("表为空\n");
        return;
    }
    int i;
    for( i=0;i<L->len;i++)
    {
        for(int j=1+i;j<L->len;j++)
        {
            if(L->data[i]==L->data[j])
            {
            //    L->data[j]=L->data[j+1];
            del_pos(L,j);
            j--;
            }
        }
    }
/*    for(i=0;i<L->len;i++)
    {
        printf("%d\n",L->data[i]);
    }*/

}

。。。

void del_pos(seq_p L,int pos)
{
        if(L==NULL)
    {
        printf("入参为空,请检查\n");
        return;
    }
    if(seq_empty(L))
    {
        printf("表为空,不能删除\n");
        return;
    }
    for(int i=pos;i<=L->len-1;i++)
    {
        L->data[i]=L->data[i+1];
    }
    L->len--;

}
 


。。。。

void insert_pos(seq_p L,datatype value,int pos)
{
    if(L==NULL)
    {
        printf("入参为空,请检查\n");
        return;
    }
    if(seq_full(L))
    {
        printf("表已满,不能插入\n");
        return;
    }
    if(pos>L->len||pos<0)
    {
        printf("位置不合理");
        return;
    }
    for(int i=L->len-1;i>=pos;i--)
    {
        L->data[i+1]=L->data[i];
    }
    L->data[pos]=value;
    L->len++;
}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值