其他分享
首页 > 其他分享> > 2.11

2.11

作者:互联网

 

 

#include<stdio.h>
typedef struct{
    int element[50];
    int length;
}SeqList;
CreateSeqList(SeqList*S)
{
    scanf("%d",&S->length);
    for(int i=0;i<S->length;i++)
    scanf("%d",&S->element[i]);
}
InsSeqList(int e,SeqList*S)
{
    int i,j;
    for(i=S->length;S->element[i-1]>e&&i>0;i--)
    S->element[i]=S->element[i-1];
    S->element[i]=e;
    S->length++;
}
OrderSeqList(SeqList S)
{
    for(int i=0;i<S.length;i++)
    printf("%d ",S.element[i]);
}
int main()
{
    SeqList S;
    int e;
    CreateSeqList(&S);
    scanf("%d",&e);
    InsSeqList(e,&S);
    OrderSeqList(S);
    return 0; 
}

 

标签:int,SeqList,element,++,length,scanf,2.11
来源: https://www.cnblogs.com/JT3895/p/15573853.html