日期:2014-05-17 浏览次数:20857 次
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
namespace SaveLoad
{
class SaveLoad
{
public:
void Save(int r[],string s)
{
ofstream os;
int i=0;
os.open(s,ios::trunc);
if(os.is_open())
{
while(!r[i])
{
os<<r[i++];
}
os.close();
}
else
{cout<<"the file can not open";exit(1);}
}
void Load(int r[],string s)
{
ifstream is;
int i=0;
is.open(s);
if(is.is_open())
{
while(!is.eof())
{
is>>r[i++];
}
is.close();
}
else
{cout<<"the file can not open";exit(1);}
}
};
}