
### 思路
 1. **创建顺序表**:从输入中读取元素个数和元素值,构造顺序表。
 2. **顺序查找**:在顺序表中依次查找关键字,找到则返回位置,否则返回0。
### 伪代码
 1. **创建顺序表**:
    - 动态分配存储空间。
    - 从输入中读取元素值并存储在顺序表中。
 2. **顺序查找**:
    - 遍历顺序表,比较每个元素与关键字。
    - 如果找到,返回元素位置。
    - 如果未找到,返回0。
### C++代码
  
#include "malloc.h" /* malloc()等 */ 
#include "stdio.h"
#include "stdlib.h"
typedef int ElemType; 
typedef struct /*静态查找表的顺序存储结构 */ 
{ 
    ElemType *elem; /* 数据元素存储空间基址,建表时按实际长度分配,0号单元留空 */ 
    int length; /* 表长度 */ 
} SSTable; 
void Creat_Seq(SSTable &ST, int n) 
{ 
    int i, temp; 
    ST.elem = (ElemType *)malloc((n + 1) * sizeof(ElemType)); /* 动态生成n个数据元素空间(0号单元不用) */ 
    if (!(ST).elem) 
    {
        printf("ERROR\n");
        exit(0);
    } /*内存分配失败结束程序*/ 
    for (i = 1; i <= n; i++) 
    { 
        scanf("%d", &temp); 
        *(ST.elem + i) = temp; /* 依次赋值给ST */ 
    } 
    ST.length = n; 
} 
int Search_Seq(SSTable &ST, ElemType key) 
{ 
    for (int i = 1; i <= ST.length; i++) 
    { 
        if (ST.elem[i] == key) 
            return i; 
    } 
    return 0; 
} 
int main() 
{ 
    SSTable ST; 
    int loc, key; 
    int n; 
    scanf("%d", &n); 
    Creat_Seq(ST, n); 
    scanf("%d", &key); 
    loc = Search_Seq(ST, key); 
    if (loc != 0) 
        printf("The element position is %d.\n", loc); 
    else 
        printf("The element is not exist.\n"); 
    return 0;
} 
### 总结
 1. **创建顺序表**:动态分配存储空间,读取元素值并存储。
 2. **顺序查找**:遍历顺序表,比较每个元素与关键字,找到则返回位置,否则返回0。



















