| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2009 人关注过本帖
标题:各位大佬求助 我是小白 请多指教我谢谢
取消只看楼主 加入收藏
一个小罗斯
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2019-10-11
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:0 
各位大佬求助 我是小白 请多指教我谢谢
图片附件: 游客没有浏览图片的权限,请 登录注册

#include <iostream>   
#include <algorithm>   
#include <vector>
#include <fstream>
#include <memory.h>   

using namespace std;
struct billion
{
    int no;
    char name[20];
    char account[6];
    int age;
    char company[20];
    char country[20];
};
ostream&  operator<<(ostream& os, billion &b)
{
    os << "编号" << '\t' << "姓名" << "\t\t" << "国家" << "\t\t" << "公司" << '\t' << "年龄" << '\t' << "资产" << endl;
    os << b.no << '\t' << b.name << '\t' << b.country << '\t' << << '\t' << b.age << '\t' << b.account << endl;
    return os;
}
class find_billion
{
private:
    billion b;
    char* country;
    int min;
    int max;
public:
    find_billion()
    {
        memset(this->country, NULL, sizeof(this->country));
        min = 0;
        max = 0;
    }
    find_billion(char *country, int min, int max)
    {
        this->country = country;
        this->min = min;
        this->max = max;
    }
    void operator()(billion b)
    {
        if (b.age > min && b.age < max && !strcmp(b.country, country))
        {
            cout << b << endl;
        }
    }
};
int main()
{
    ifstream in;
    in.open("d:\\billion.bin");
    vector<billion>v;
    billion b;
    in.read((char *)&b, sizeof(billion));
    while (!in.eof())
    {
        in.read((char *)&b, sizeof(billion));
        v.push_back(b);
    }

    find_billion bil = for_each(v.begin(), v.end(), find_billion("China", 60, 70));
    in.close();
    return 0;
}
搜索更多相关主题的帖子: max char int min include 
2019-10-11 18:11
快速回复:各位大佬求助 我是小白 请多指教我谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013078 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved