📄 sort.cpp
字号:
#include<iostream>
#include<vector>
#include<string>
#include<fstream>
#include<algorithm>
using namespace std;
int main()
{
ifstream infile("e:\\vc++\\text.txt");
if(! infile)
cerr << "Oops, Unable to open input file! "<< endl;
ofstream outfile("e:\\vc++\\text.sort");
if(! outfile)
cerr << "Oops,Unable to open output file! "<< endl;
string word;
vector<string> text;
while(infile >> word)
{
text.push_back(word);
}
int ix;
cout << "Unsorted text: " << endl;
for(ix=0;ix<text.size();++ix)
cout << text[ix] << " ";
cout << endl;
sort(text.begin (),text.end());
outfile << "The sorted text: \n ";
for (ix=0;ix<text.size();++ix)
outfile << text[ix]<< " ";
outfile << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -