首先出题者的专业水平不行,存储文件中 struct billion 使用 int 类型,而 int 在标准中只要求其不小于2字节,在已知的编译器中,它可能是2字节、4字节、8字节;除此之外,结构体还有字节对齐问题,不同的编译器包括同一个编译器的不同编译选项都可能影响到它。
其次,出题者在专业知识之外也是个稀里糊涂的混混儿。“调用find_billion(“China”, 38, 45),打印出满足要求的所有富翁。”请问是什么条件,是它小姨子的腰围胸围必须是38和45吗?

程序代码:
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
struct billion
{
    int no;
    char name[20];
    char account[6];
    int age;
    char company[20];
    char country[20];
};
int main( void )
{
    vector<billion> bs;
    {
        ifstream file( "billion.bin" );
        if( !file )
        {
            cerr << "the file open failed.\n";
            return 1;
        }
        for( billion b; file.read((char*)&b,sizeof(b)) && file.gcount()==sizeof(b); )
            bs.push_back( b );
    }
    class find_billion
    {
    public:
        find_billion( const char* country, int minval, int maxval ) : minval_(minval), maxval_(maxval)
        {
            strcpy( country_, country );
        }
        void operator()( const billion& b ) const
        {
            if( b.age>=minval_ && b.age<=maxval_ && strcmp(b.country,country_)==0 ) // 你得问到出题者的意图后,然后修改此句的条件
                cout << b.no << ", " << b.name << ", " << b.account << ", " << b.age << ", " <<  << ", " << b.country << '\n';
        }
    private:
        char country_[20];
        int minval_, maxval_;
    };
    for_each( bs.begin(), bs.end(), find_billion("China",60,70) );
    return 0;
}