程序运行到一半,报错该内存不能read,求助
#include<iostream>#include<fstream>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include <iomanip>
using namespace std;
#define MAX 20
int Number,Money; //全局量:项目个数,投资金额
,投资收益
float maxincome;
typedef struct
{
char name[MAX];
float money[MAX];
float power[1][MAX];
int invest_num;
}Project;
void Input(Project *pro[]) //项目信息输入
{
int i,j;
cout<<"请输入投资项目个数:"<<endl;
cin>>Number;
cout<<"请输入投资资金:"<<endl;
cin>>Money;
for(i=0;i<Number;i++)
{
pro[i]=new Project;
cout<<"请输入第"<<i+1<<"个项目名称\n";
cin>>pro[i]->name;
cout<<"请输入投入相应资金的收益:\n";
for(j=0;j<Money;j++)
{
cin>>pro[i]->money[j+1];
pro[i]->power[0][j+1]=j+1;
}
}
}
void Powersort(Project *pro[]) //插入排序法函数:将一个项
目权重从大到小排序
{
int i,j,k;
double key;
for(k=0;k<Number;k++)
{
for(i=0;i<Money;i++)
pro[k]->power[1][i+1]=pro[k]->money[i+1]/(i+1);
for(i=2;i<=Money;i++)
{
key=pro[k]->power[1][i];
for(j=i-1;j>=1;j--)
if(pro[k]->power[1][j]<key)
{
pro[k]->power[1][j+1]=pro[k]->power[1][j];
pro[k]->power[1][j]=key;
}
}
}
}
void Projectsort(Project *pro[]) //根据权重选出要投资的项
目
{
int invest_tag=0;
int i,j,k;
int count=0;
double key;
Project *c;
c=new Project;
for(k=1;invest_tag=Money;k=Money-invest_tag)
{
count=count+1;
for(i=count+1;i<=Money;i++) //插入排序
{
key=pro[i]->power[1][k];
for(j=i-1;j>=count-1;j--)
{
if(pro[j]->power[1][k]<key)
{
c=pro[j+1];
pro[j+1]=pro[j];
pro[j]=c;
}
pro[j]->power[1][1]=key;
}
}
pro[count-1]->invest_num=pro[count-1]->power[0][k];
invest_tag=invest_tag+pro[count-1]->power[0][k];
maxincome=maxincome+pro[count-1]->invest_num;
}
delete c;
}
void Write(Project *pro[]) //结果的输出
{
int i;
cout<<"*******************最终的投资结果*******************"<<endl;
cout<<"投资金额项目"<<"\t"<<"投资金额"<<endl;
for(i=0;i<Number;i++)
{
cout<<pro[i]->name<<"\t"<<pro[i]->invest_num<<endl;
}
cout<<"最大投资收益额:"<<maxincome<<endl;
}
void main()
{
cout<<"**********************************************************************"<<endl;
cout<<"****************** 银行风险投资收益分析程序 ******************"<<endl;
cout<<"**********************************************************************"<<endl;
char sign;
cout<<"**********************输入Y,开始程序;任意键退出*********************\n";
sign=getchar();
if(sign=='Y')
{
Project *pro[MAX];
Input(&pro[MAX]);
Powersort(&pro[Number]);
Projectsort(&pro[Number]);
Write(&pro[Number]);
}
else
exit(1);
}