You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
p5pkulzmh 6636f69a91
Update README.md
2 years ago
README.md Update README.md 2 years ago

README.md

#include #include <string.h> //#include<stdlib.h> //#include<stdio.h> using namespace std; #define OK 1 #define Maxsize 100 #define OVERFLOW -2 using namespace std; typedef int Status; typedef struct { char no[20]; char name[50]; float price; }Book; typedef struct { Book elem; int length; }SqList; int main() { Status InitList(SqList &L); Status PrintList_Sq(SqList &L); Status CreationList_Sq(SqList &L,charno,char*name,float &price); SqList L; InitList(L); char no[20],name[50]; float price; int i=0; while(1) { cin>>no>>name>>price; if(*no=='0'&&*name=='0'&&price==0){break;} CreationList_Sq(L,no,name,price); ++i; } cout<<i<<endl; PrintList_Sq(L); return 0; } Status InitList(SqList &L) { L.elem=new Book[Maxsize]; if(!L.elem) exit(OVERFLOW); L.length=0; return OK; } Status CreationList_Sq(SqList &L,char *no,char *name,float &price) { Book B; strcpy(B.no,no); strcpy(B.name,name); B.price=price; L.elem[L.length]=B; L.length++; return OK; } Status PrintList_Sq(SqList &L) { for(int i=0;i<L.length;i++) { cout<<L.elem[i].no<<" "<<L.elem[i].name<<" "; printf("%.2f\n",L.elem[i].price); } return OK; }