📄 sortwlen.cpp
字号:
#include <iostream>#include <fstream>#include <string>using namespace std;#include "tvector.h"#include "prompt.h"#include "sortall.h"// illustrates templates, read words, sort words, print wordstemplate <class Type>void Print(const tvector<Type>& list, int first, int last)// post: list[first]..list[last] printed, one per line{ int k; for(k=first; k <= last; k++) { cout << list[k] << endl; }}int main(){ tvector<string> wordList; tvector<int> lengthList; string filename = PromptString("filename: "); string word; ifstream input(filename.c_str()); while (input >> word) { wordList.push_back(word); lengthList.push_back(word.length()); } SelectSort(wordList,wordList.size()); SelectSort(lengthList,lengthList.size()); Print(wordList,wordList.size()-5,wordList.size()-1); Print(lengthList,lengthList.size()-5,lengthList.size()-1); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -