zoukankan      html  css  js  c++  java
  • 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9

    #include <iostream>
    #include <fstream>
    #include <cstdlib>
    #include <string>
    using namespace std;
    struct patron
    {
    	double mon;
    	string name;
    };
    int main()
    {
    	int num,count1=0,count2=0;
    	ifstream fin;
    	char filename[20];
    	cout<<"Enter name of data file: ";
    	cin.get(filename,20);
    	fin.open(filename);
    	if(!fin.is_open())
    	{
    		cout<<"Could not to open the file "<<filename<<endl;
    		cout<<"Program termination.
    ";
    		exit(EXIT_FAILURE);
    	}
    	fin>>num;
    	fin.get();
    	patron *newp=new patron[num];
    	for(int i=0;i<num;i++)
    	{
    		getline(fin,newp[i].name);
    		fin>>newp[i].mon;
    		fin.get();
    	}
    	cout<<"Grand Patrons:
    ";
    	for(int j=0;j<num;j++)
    	{
    		if(newp[j].mon>10000)
    		{
    			cout<<newp[j].name<<":"<<newp[j].mon<<endl;
    			count1++;
    		}
    		if(count1==0)
    			cout<<"none
    ";
    		cout<<"Patrons:
    ";
    		for(int k=0;k<num;k++)
    		{
    			if(newp[k].mon<=10000)
    			{
    				cout<<newp[k].name<<":"<<newp[k].mon<<endl;
    				count2++;
    			}
    		}
    		if(count2==0)
    			cout<<"none
    ";
    	}
    	delete [] newp;
    	system("pause");
    	return 0;
    }
    
  • 相关阅读:
    springmvc,springboot单元测试配置
    uboot中ftd命令
    在根文件系统中查看设备树(有助于调试)
    协议类接口
    网络设备接口
    块设备驱动框架
    i2c子系统
    触摸屏
    input子系统
    原子访问、自旋锁、互斥锁、信号量
  • 原文地址:https://www.cnblogs.com/lynnycy/p/3455038.html
Copyright © 2011-2022 走看看