⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sort.cpp

📁 包含C++中map
💻 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 + -