#include <iostream>
using namespace std;
int main()
{
cout << "共多少位捐款者(输入 0 程序结束):";
int sum;
cin >> sum;
cin.get();
if ( sum > 0 )
{
information * donor = new information[sum];
for ( int number = 0; number < sum; ++number)
{
cout << number + 1 << ")位捐款者:";
getline(cin, donor[number].name);
cout << " 捐款数额:";
while( !( cin >> (donor+number)->momey ) || (donor+number)->momey <= 0 ) 这里有疑问
{
cin.clear();
while ( cin.get() != '\n' )
{
continue;
}
cout << "请输入( > 0 )的数字:";
}
cin.get();
}
cout << "\n重要捐款者(Grand Patrons):\n";
int grand_patrons = 0;
for ( int gp = 0; gp < sum; ++gp )
{
if ( donor[gp].momey > GRAND )
{
cout << gp + 1 << ")捐款者:" << donor[gp].name << " 捐款数额:" << donor[gp].momey << endl;
++grand_patrons;
}
}
if ( grand_patrons == 0 ){cout << "无(none)。\n";}
cout << "\n其他捐款者(Patrons):\n";
if ( grand_patrons != sum )
{
for ( int gp = 0; gp < sum; ++gp )
{
if ( donor[gp].momey <= GRAND )
{
cout << gp + 1 << ")捐款者:" << donor[gp].name << " 捐款数额:" << donor[gp].momey << endl;
}
}
}
else
{
cout << "无(none)。\n";
}
cout << endl;
delete [] donor;
}
else{cout << "无(none)。\n";}
return 0;
}
中间输入钱的那里,donor+number的意思是什么,我删掉后程序运行后输出了一串地址。。。
再次感谢大神!!!!
onemoo
相关分类