#include #include #include #include #include #include "pics.h" using std::cout; using std::copy; using std::endl; using std::ostream_iterator; using std::string; using std::vector; int main() { vector p; p.push_back("this is an"); p.push_back("example"); p.push_back("to"); p.push_back("illustrate"); p.push_back("framing"); ostream_iteratorofile(cout, "\n"); copy(p.begin(), p.end(), ofile); cout << endl; vector f = frame(p); copy(f.begin(), f.end(), ofile); cout << endl; vector h = hcat(p,frame(p)); copy(h.begin(), h.end(), ofile); cout << endl; return 0; } #include // 引入算法库,提供常用的算法 #include // 引入标准输入输出流库 #include // 引入迭代器库 #include // 引入字符串库 #include // 引入动态数组(vector)库 #include "pics.h" // 引入自定义的 pics.h 库(假设此库包含框架生成和拼接相关的功能) using std::cout; // 使用标准输出流 using std::copy; // 引入copy算法 using std::endl; // 引入换行符 using std::ostream_iterator; // 引入输出流迭代器,用于输出容器的内容 using std::string; // 使用字符串类型 using std::vector; // 使用vector容器 int main() { // 创建一个vector类型的容器 p,存储字符串 vector p; p.push_back("this is an"); // 添加一个字符串 p.push_back("example"); // 添加一个字符串 p.push_back("to"); // 添加一个字符串 p.push_back("illustrate"); // 添加一个字符串 p.push_back("framing"); // 添加一个字符串 // 创建输出流迭代器,指定输出到 cout,并且每个元素输出后换行 ostream_iterator ofile(cout, "\n"); // 使用copy算法,将vector p中的内容逐个输出 copy(p.begin(), p.end(), ofile); cout << endl; // 输出换行符 // 对vector p应用框架操作,生成一个新的vector f vector f = frame(p); // 使用copy算法,将vector f中的内容逐个输出 copy(f.begin(), f.end(), ofile); cout << endl; // 输出换行符 // 将vector p和vector f进行横向拼接,生成一个新的vector h vector h = hcat(p, frame(p)); // 使用copy算法,将vector h中的内容逐个输出 copy(h.begin(), h.end(), ofile); cout << endl; // 输出换行符 return 0; // 程序正常结束 }