65,186
社区成员




#include <vector>
#include <string>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
ifstream in("txt1.txt");
ofstream out("txt2.txt");
string line;
vector<string> lines;
while(getline(in, line))
lines.push_back(line);
if(lines.size() == 0) return 0;
int num = 0;
const int width = int(log10((double)lines.size())) + 1;
out.setf(ios::right, ios::adjustfield);
for(string::size_type i = 0; i < lines.size(); i++)
{
out.width(width);
out << ++num << ") " << lines[i] << endl;
}
in.close();
out.close();
}