Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2349796
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:07:42

#include "iostream"
using namespace std;
const int n=5;
void he();
class BOOK{
      public:
      string name;
      string author;
      string state;
      int ID;
      float price;
      int po;
      BOOK()
      {    
            ID=0;
            name="null";
            author=" ";
            state="在馆";
            price=0;
            po=0;
            }
void addbook()
{    
             
             cout<<"请输入书名:";
             cin>>name;
             cout<<"请输入作者:";
             cin>>author;
             cout<<"请输入书价格:";
             cin>>price;
             }
void findbook()
{  
for(int i=po;i{     po++;
      if(name=="null")
{
cout<<"是否~继续添加Y/N?";
char t;
cin>>t;
 if(t=='Y'||'y')
         {
         addbook();
         ID++;
         }
 if(t=='N'||'n')
{ break;}
}
 if(name!="null")    
 { cout<<"书位已经满了"<   break;
      }
      }
      }

void sharebook()
{
cout<cout<cout<cout<}
                   
            };BOOK book[n];
int main()
{
    he();
     cout<<"现有图书:"<       cout<<"书号"<<"\t";
      cout<<"书名"<<"\t";
     cout<<"作者"<<"\t";
    cout<<"价格"<<"\t"<for(int i=0;i{
       
    book[i].sharebook();
}

    system("pause");
}

void he()
{

    int m;
    char o;
    int out=1;
    while(out)
    {
       cout<<"添加图书输入Y/或查询现有图书输入N?";
       cin>>o;
    if(o=='y'||o=='Y')
    {  m=0;
       book[m].findbook();
       m++;
       }
    if(o=='N'||o=='n')
    out=0;
}
}


我请他 吃糖哦


--------------------next---------------------
#include      //用户自己的头文件才用""双引号,这只是个习惯问题!
#include        //你没有string类头文件,给你加了

using namespace std;

const int n=5;

void he();

class BOOK {
public:
    string name;
    string author;
    string state;
    int ID;
    float price;
    int po;
    BOOK() {
        ID=0;
        name="null";
        author=" ";
        state="在馆";
        price=0;
        po=0;
    }
    void addbook() {
        cout<<"请输入书名:";
        cin>>name;
        cout<<"请输入作者:";
        cin>>author;
        cout<<"请输入书价格:";
        cin>>price;
    }
    void findbook() {
        for(int i=po;i            po++;
            if(name=="null") {
                cout<<"是否~继续添加Y/N?";
                char t;
                cin>>t;
                if(t=='Y'||'y') {
                    addbook();
                    ID++;
                }
                if(t=='N'||'n') {
                    break;
                }
            }
            if(name!="null") {
                cout<<"书位已经满了"<                break;
            }
        }
    }

    void sharebook() {
        cout<        cout<        cout<        cout<    }

};

BOOK book[n];

int main() {
    he();
    cout<<"现有图书:"<    cout<<"书号"<<"\t";
    cout<<"书名"<<"\t";
    cout<<"作者"<<"\t";
    cout<<"价格"<<"\t"<    for(int i=0;i        book[i].sharebook();
    }
    system("pause");
    return 0;           //这里再加1个返回,不加也行,1个好的习惯,还是加上吧!
}

void he() {
    int m;
    char o;
    int out=1;
    while(out) {
       cout<<"添加图书输入Y/或查询现有图书输入N?";
       cin>>o;
        if(o=='y'||o=='Y') {
            m=0;
            book[m].findbook();
            m++;
        }
        if(o=='N'||o=='n')
        out=0;
    }
}

--------------------next---------------------

阅读(1003) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~