#include <iostream>
#include <string>
#include <fstream>
using namespace std;
const int Money = 10000;
struct Patrons
{
string name;
double money;
};
int main()
{
ifstream inFile;
inFile.open("demo6_9.txt");
if(!inFile.is_open())
{
cout<<"could not open the file \"demo6_9\"\n";
cout<<"program terminating!\n";
exit(EXIT_FAILURE);
}
int num;
inFile>>num;
cout<<"the number of Patrons is :"<<num<<"."<<endl;
inFile.get();//读取换行符
// string name;
// int money;
Patrons *pt = new Patrons[num];
if(inFile.is_open())
{
int i;
for(i=0;i<num;i++)
{
// inFile>>name;
// inFile>>money;
// pt[i].name = name;
// pt[i].money = money;
getline(inFile,pt[i].name); //读取一行输入
(inFile>>pt[i].money).get();
}
int k=0;
cout<<"Grand Patrons:"<<endl;
for(i=0;i<num;i++)
if(pt[i].money >= Money)
{
cout<<pt[i].name<<" "<<pt[i].money<<endl;
k++;
}
if(k==0)
cout<<"none.\n";
cout<<"Patrons:"<<endl;
if(k==num)
cout<<"none.\n";
else
{
for(i=0;i<num;i++)
if(pt[i].money < Money)
cout<<pt[i].name<<" "<<pt[i].money<<endl;
}
}
inFile.close();
delete [] pt;
system("pause");
return 0;
}