赞
踩
- #include<stdio.h>
- #include<stdlib.h>
- #define maxsize 100
- typedef int elemtype;
- typedef struct{
- int list[maxsize];
- int length;
- }sqlist;
-
- //顺序表的初始化
- void relist(sqlist *L){
- (*L).length = 0;
- //等价于L->length = 0;
- }
-
- void creatlist(sqlist *L,int n){
- for(int i=0;i<n;i++){
- scanf("%d",&L->list[i]);
- L->length++;
- }
- }
- void printflist(sqlist *L,int n){
- for(int i=0;i<n;i++){
- printf("%d ",L->list[i]);
- L->length++;
- }
- }
-
- int main(){
- int n;
- sqlist L;
- relist(&L);
- printf("输入几个数:");
- scanf("%d",&n);
- creatlist(&L,n);
- printflist(&L,n);
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。