可不可以把帮我看看这C++编程有什么问题~~~

来源:百度知道 编辑:UC知道 时间:2024/06/20 11:44:36
#include<iostream.h>
#include<iomanip.h>
#include<string.h>
struct book
{
char title[10];
int amount;
float price;
};
void main()
{
static struct book b[ ]={{"Pascal",40,21.5},{"FoxPro",50,20.0},{"C",80,25.0}};
cout<<setw(10)<<"Title"<<setw(10)<<"Amount"<<setw(10)<<"Price"<<endl;
cout<<setw(10)<<b[0].title<<setw(10)<<b[0].amount<<setw(10)<<b[0].price<<endl;
cout<<setw(10)<<b[1].title<<setw(10)<<b[1].amount<<setw(10)<<b[1].price<<endl;
cout<<setw(10)<<b[2].title<<setw(10)<<b[2].amount<<setw(10)<<b[2].price<<endl;
struct book *b1,*find(struct book b[ ]);
int n;
float p;
b1=find(b);
if(b1==0)
cout<<"We don't h

cin>>b[3].title>>b[3].amount>>b[3].price;
cout<<b[3].title<<b[3].amount<<b[3].price<<endl;

看到了这一行。
b最大就是3个元素,所以下标最大为2.
你这个就肯定不对了

看到第一行include就不想看了,写程序一点都不按照标准来。

看到第一行include就不想看了