题目;基于顺序存储结构的图书信息表的创建和输出
#include<bits/stdc++.h>
using namespace std;
#define maxsize 10000
typedef int Status;
typedef struct
{
char no[20];
char name[50];
double price;
}book;
typedef struct
{
book *elem;
int length;
}SqList;
void InitList(SqList &l)
{
l.elem=new book[maxsize];
if(!l.elem) exit(OVERFLOW);
l.length=0;
}
int main()
{
int j,i=0;
SqList l;
InitList(l);
while(1)
{
scanf("%s %s %lf/n",&l.elem[i].no,&l.elem[i].name,&l.elem[i].price);
if(l.elem[i].no[0]=='0'&&l.elem[i].name[0]=='0'&&l.elem[i].price==0)
break;
i++;
}
printf("%d\n",i);
for(j=0;j<i;j++)
printf("%s %s %.2f\n",l.elem[j].no,l.elem[j].name,l.elem[j].price);
return 0;
}