oj上一个c++,有关类的题目

这个是题目。
输入的时候怎么这样子??查了好久查不出来,求大神指点

#include <iostream>
#include <iomanip>
using namespace std;
class book
{
public:
book () {}
book(int t,int b)
{
type = t;bno = b;
}
int type;//类型
int bno;//编号
};
class lbook:public book
{
public:
lbook () {}
lbook(int t,int b,int s):book(t,b)
{
storage = s;
}
void set(int t,int b,int s)
{
storage = s;
}
int storage;
};
class pbook :public book
{
public:
pbook () {}
pbook(int t,int b,double p):book(t,b)
{
price = p;
}
void set(int t,int b,double p)
{
price = p;
}
double price;
};
int main()
{
int storge_total = 0;
double price_total = 0;
int count_pbook = 0;
int l = 0,p = 0;
book* lb[10000],* pb[1000];
int type,bno;
double st_pri;
cin >> bno >> type >> st_pri;
while(cin)
{
if (type == 0)
{
pb[p] = new pbook(type,bno,st_pri);
count_pbook ++;
price_total += st_pri;
p++;
}
if (type == 1)
{
lb[l] = new lbook(type,bno,st_pri);
storge_total += st_pri;
l++;
}
cin >> bno >> type >> st_pri;
}
for (int j = 0;j <= l;j++)
{
if (lb[j] -> type == 1)//文学
cout << lb[j] -> bno << " " << lb[j] -> type << " " << ((lbook*)lb[j]) -> storage << endl;
else continue;
}
for (int t = 0;t <= p;t++)
{
if (pb[t] -> type == 0)//理学
cout << pb[t] -> bno << " " << pb[t] -> type << " " << ((pbook*)pb[t]) -> price << endl;
else continue;
}
cout << storge_total << endl;
cout.setf(ios::fixed);
cout << setprecision(1);
cout << price_total / count_pbook << endl;
return 0;
}
...全文
相关推荐
适合新手的oj题
适合新手的oj题,c/c++,高手请无视
华为题目部分集合OJ
主要是华为OJ平台上面的一些代码,希望对你们有些帮助。
C&&DS&&C++相关内容及代码记录,及一些OJ题目.zip
C&&DS&&C++相关内容及代码记录,及一些OJ题目.zip
杭电oj基础100题-下载即用.zip
代码下载链接: https://pan.quark.cn/s/00128084e959 这组题号属于杭州电子科技大学在线 judge 系统的入门级100个题目,完成这些题目能够帮助学习者熟悉并掌握基础的输入输出处理以及初步的算法知识。
OnlineJudgeDemo
本程序简单的实现了OnlineJudgeDemo,基于VC++平台测试成功,希望大家下载!



