标签:cout ios def new book price 结构体 单链表 bsp
#include <iostream> #include <stdio.h> using namespace std; #define OK 1 #define ERROR 0 #define OVERFLOW -2 int num=0; typedef struct Book { string IS; string Name; float price; Book *next; }Book,*PBook; PBook Create() { PBook Head=new Book; PBook Tail=new Book; PBook New; string t1,t2; float t3; Tail=Head; while(cin>>t1>>t2>>t3&&t3) { num++; New=new Book; New->IS=t1; New->Name=t2; New->price=t3; Tail->next=New; New->next=NULL; Tail=New; } return Head; } void Print(PBook pHead) { PBook p; p=pHead->next; cout<<num<<endl; while(p!=NULL) { cout<<p->IS<<" "<<p->Name; printf(" %.2f\n",p->price); p=p->next; } } int main() { PBook Head; Head=Create(); Print(Head); return 0; }
标签:cout ios def new book price 结构体 单链表 bsp
原文地址:https://www.cnblogs.com/tsj816523/p/11546430.html