#ifndef ARRAY_H
#define ARRAY_H
#define ERR 0
#define OK 1
#include
typedef int Elemtype;
typedef int Status;
typedef struct {
Elemtype *iva;
int size;
} Array;
Status init( Array *pev, int sz ) {
pev->iva = ( Eelemtype* ) malloc ( sz * sizeof ( Elemtype ) );
if( !pev->iva )
return ERR;
pev->size = sz;
return OK;
}
Status w_array( Array *op ) {
int ix;
if( !op )
return ERR;
printf( "请输入%d个数:",op->size );
for( ix = 0; ix < op->size; ++ix )
scanf( "%d", &op->iva[ ix ] );
return OK;
}
Status print( Array *op ) {
int ix;
if( !op )
return ERR;
printf( "正在输出%d个数:",op->size );
for( ix = 0; ix < op->size; ++ix )
printf( "%d ", op->iva[ ix ] );
printf( "\n" );
return OK;
}
elemtype find( array *op,int xi ) {
if( !op )
return ERR;
return op->iva[ xi ];
}
#endif