这段代码有问题吗,在编译的时候会出现崩溃的现象
#include <iostream>#include <string>
#include <cstring>
using namespace std;
struct donation
{
string name;
double money;
};
int main ()
{
int n_of_donation=0;
cout<<"输入捐款者的数目:\n";
cin>>n_of_donation;
donation *list=new donation[n_of_donation];
for(int i=0;i<n_of_donation;i++)
{
cout<<"输入第 "<<i+1<<" 位捐款者的信息:\n";
cout<<"name:\n";
cin>>list[i].name;
cout<<"money:\n";
cin>>list[i].money;
}
int temp=0;
cout<<"重要捐款人:"<<endl;
for(int m=0;m<n_of_donation;m++)
{
if(list[m].money>10000)
{
cout<<list[m].name<<" "<<list[m].money<<endl;
temp++;
}
}
if(temp==0)
cout<<"None.\n";
temp=0;
cout<<"捐款人: "<<endl;
for(int o=0;o<n_of_donation;o++)
{
if(list[o].money<=10000)
{
cout<<list[o].name<<" "<<list[o].money<<endl;
temp++;
}
}
if(temp==0)
cout<<"None!\n";
delete list;
getchar();
getchar();
return 0;
}