回覆列表
  • 1 # 使用者436371273386

    #include<stdio.h>

    #include<malloc.h>

    #include<stdlib.h>

    #define ADDRESS 100

    #define ZL 10

    typedef struct

    {

    int *elem;

    int length;

    int size;

    }LIST;

    LIST create()

    {

    LIST L;

    L.elem=(int *)malloc(ADDRESS*sizeof(int));

    L.length=0;

    L.size=ADDRESS;

    return L;

    }

    int input(LIST L,int n)

    {

    int i;

    printf("please input your nums:");

    for(i=0;i<n;i++)

    scanf("%d",L.elem++);

    return 1;

    }

    void output(LIST L)

    {

    int i;

    printf("LIST=(");

    for(i=0;i<L.length;i++)

    printf("%2d",*L.elem++);

    printf(")\n");

    }

    int find(LIST L,int x)

    {

    int i,seat;

    for (i=0;i<L.length;i++)

    {

    if(x==*L.elem++)

    { seat=i+1;

    break;

    }

    }

    if(i==L.length)

    printf("CAN"T FIND %d\n",x);

    return seat;

    }

    void main()

    {

    LIST L;

    int i,j,n,a,b,x,SEAT;

    printf("pleases input the amount of nums:");

    scanf("%d",&n);

    L=create();

    input(L,n);

    L.length=n;

    printf("please input the number you want to find:");

    scanf("%d",&x);

    SEAT=find(L,x);

    printf("the seat is %d \n",SEAT

  • 中秋節和大豐收的關聯?
  • 艾瑞澤5和瑞虎3該怎麼選?