📄 ex10_05.cpp
字号:
// Ex10_05.cpp
// Working with a list
#include <iostream>
#include <list>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::list;
using std::string;
int main()
{
list<string> text;
list<string>::iterator iter; // Stores an iterator
// Read the data
cout << "Enter a few lines of text. Just press Enter to end:"
<< endl;
string sentence;
while(getline(cin, sentence, '\n'), !sentence.empty())
text.push_front(sentence);
// Output the dat using an iterator
cout << endl << "Here is the text you entered:" << endl;
for(iter = text.begin() ; iter != text.end() ; iter++)
cout << *iter << endl;
// Sort the data in ascending sequence
cout << endl << "In ascending sequence the sentences you entered are:" << endl;
text.sort();
for(iter = text.begin() ; iter != text.end() ; iter++)
cout << *iter << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -