编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习6

#include <iostream>
#include <string>
using namespace std;
const int MSIZE=100;
struct juankuan
{
string name;
double mon;
};
int main()
{
int num;
(cin>>num).get();
int *c1=new int[num];//存储捐款超过10000的捐款个体
int count1=0;//记录捐款超过10000的个数
int *c2=new int[num];//存储捐款超过10000的捐款个体
int count2=0;
juankuan *newjk=new juankuan[num];
int i=0;
while(i<num)
{
cout<<"Enter the name of patron: ";
getline(cin,newjk[i].name);
cout<<"Enter the money of patron: ";
cin>>newjk[i].mon;
cin.get();
if(newjk[i].mon>10000)
{
c1[count1++]=i+1;
}
else
{
c2[count2++]=i+1;
}
i++;
}
cout<<"Grand Patrons: "<<endl;
int j=0,k;
if(count1==0)
cout<<"none"<<endl;
else
{
while(j<count1)
{
k=c1[j];
cout<<newjk[k-1].name<<":"<<newjk[k-1].mon<<endl;
j++;
}
}
int n=0,m;
cout<<"Partons: "<<endl;
if(count2==0)
cout<<"none"<<endl;
else
{
while(n<count2)
{
m=c2[n];
cout<<newjk[m-1].name<<":"<<newjk[m-1].mon<<endl;
n++;
}
}
delete [] newjk;
delete [] c1;
delete [] c2;
system("pause");
return 0;
}
上一篇:获取SQL数据库表空间结构


下一篇:编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习9