zoukankan      html  css  js  c++  java
  • 编程菜鸟的日记-初学尝试编程-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;
    }
    
    
    
    
  • 相关阅读:
    Eleven-面向对象进阶
    Ten-面向对象
    Nine-常用模块
    Eight-内置函数和匿名函数
    Seven-递归函数和装饰器函数
    Six-迭代器和生成器
    Five-函数
    Four-深浅copy和文件操作
    Third-基础数据类型
    Second-基础
  • 原文地址:https://www.cnblogs.com/lynnycy/p/3454807.html
Copyright © 2011-2022 走看看