#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++;
}