64,691
社区成员
发帖
与我相关
我的任务
分享
#include "iostream"
#include "fstream"
#include "vector"
#include "string"
using namespace std;
int main()
{
ifstream ifile("test.txt");
if (ifile.fail())
return 1;
vector<string> vtext;
while (!ifile.eof())
{
string str;
getline(ifile, str);
vtext.push_back(str);
}
ifile.close();
ofstream ofile("out.txt");
vector<string>::reverse_iterator i = vtext.rbegin();
while (i != vtext.rend())
{
ofile<<(*i)<<endl;
++i;
}
ofile.close();
return 0;
}