丷梦七仙丷吧 关注:15贴子:333
  • 2回复贴,共1
#include"sj.h"
typedef struct
{
ElemType elem[MAXSIZE];
int length;
}
SeqList;
void Create_SeqList(SeqList *L)
{
int i,n,num;
char ss[8];
float score;
printf("please input list length:\n");
scanf("%d",&n);
L->length=n;
for(i=1;i<=n;i++)
{
printf("please input Num,Name,Score:\n");
scanf("%d",&num);
getchar();gets(ss);
scanf("%f",&score);
L->elem[i].Num=num;
strcpy(L->elem[i].Name,ss);
L->elem[i].Score=score;
}
}
void Print_SeqList(SeqList *L)
{
int i;
printf("The LIST is:\n");
for(i=1;i<=L->length;i++)
printf("num=%d,Name=%s,csore=%f\n",L->elem[i].Num,L->elem[i].Name,L->elem[i].Score);
}
Status Insert_SeqList(SeqList *L,int i,ElemType x)



1楼2008-03-27 11:31回复
    #include"sj.h"
    typedef struct
    {
    ElemType elem[MAXSIZE];
    int length;
    }
    SeqList;
    void Create_SeqList(SeqList *L)
    {
    int i,n,num;
    char ss[8];
    float score;
    printf("please input list length:\n");
    scanf("%d",&n);
    L->length=n;
    for(i=1;i<=n;i++)
    {
    printf("please input Num,Name,Score:\n");
    scanf("%d",&num);
    getchar();gets(ss);
    scanf("%f",&score);
    L->elem[i].Num=num;
    strcpy(L->elem[i].Name,ss);
    L->elem[i].Score=score;
    }
    }
    void Print_SeqList(SeqList *L)
    {
    int i;
    printf("The LIST is:\n");
    for(i=1;i<=L->length;i++)
    printf("num=%d,Name=%s,csore=%f\n",L->elem[i].Num,L->elem[i].Name,L->elem[i].Score);
    }
    Status Insert_SeqList(SeqList *L,int i,ElemType x)
    {
    int j;
    if(i<1||i>L->length+1) return ERROR;
    if(L->length==MAXSIZE-1) return OVERFLOW;
    for(j=L->length;j>=i;j--)
    L->elem[j+1=L->elem[j];
    L->elem[i]=x;
    ++L->length;
    return OK;
    }
    Status Delete_SeqList(SeqList *L,int i)
    {
    int j;
    if(i<1 || i>L->length)
    {
    printf("不存在第i个元素");
    return ERROR;
    }
    for(j=i;j<=L->length-1;j++)
    L->elem[j]=L->elem[j+1];
    L->length--;
    return OK;
    }


    2楼2008-03-27 11:41
    回复
      #include<string.h>
      #include<stdio.h>
      #include<time.h>
      #define MAXSIZE 60
      #define TRUE 1
      #define FALSE 0
      #define OK 1
      #define ERROR 0
      #define OVERFLOW -1
      typedef int Status;
      typedef struct std_info{
      int Num;
      char Name[8];
      float Score;
      }ElemType;


      3楼2008-03-27 11:42
      回复