#include<iostream>#include<fstream>#include<cstdlib>#include<string>using namespace std;struct Patron{?char name[20];?double money;};int main(){?cout << "請輸入捐獻(xiàn)者數(shù)目";?ifstream inFile;?inFile.open("homework6_9.txt");?if (!inFile.is_open())?{??cout << "Could not open the file." << endl;??exit(EXIT_FAILURE);?}??int num;?inFile >> num;?inFile. get();?char ch;?inFile >> ch;?Patron *p = new Patron[num];??for (int i = 0; i < num; i++)??{???inFile.get();???getline(inFile, p[i].name); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //未找到匹配的重載函數(shù)???inFile >> p[i].money;??}??cout << "Geand Patrons" << endl;??int count1 = 0;??int count2 = 0;??for (int i = 0; i < num; i++)??{???if (p[i].money > 10000)???{????cout << p[i].name <<" , "<<p[i].money<< endl;????count1++;???}???if (count1 == 0)????cout << "none" << endl;??}??cout << "Other Patrons";??for (int i = 0; i < num; i++)??{???if (p[i].money <= 10000)???{????cout << p[i].name << " , "<<p[i].money<<endl;????count2++;???}???if (count2 == 0)????cout << "none" << endl;??}?inFile.close();?return 0;}
- 1 回答
- 0 關(guān)注
- 2213 瀏覽