当前位置: 首页 > news >正文

南美洲网站后缀邯郸北京网站建设

南美洲网站后缀,邯郸北京网站建设,规避电子政务门户网站建设的教训,wordpress首次访问很卡慢个人认为#xff0c;结合网上对《Essential c》的评论#xff0c;它不适合初学者#xff1a; #xff08;1#xff09;过于精炼#xff0c;很多内容不会细讲 #xff08;2#xff09;中文版翻译较生硬#xff0c;逻辑不够连贯清晰 #xff08;3#xff09;课后作业有…个人认为结合网上对《Essential c》的评论它不适合初学者 1过于精炼很多内容不会细讲 2中文版翻译较生硬逻辑不够连贯清晰 3课后作业有答案但是没提供网上可编译的源码网站开梯无法访问手敲完可能一堆BUG或者是片段式的答案即不是完整代码 看的我一脸懵第5章的代码就不敲了后续看情况 目录 4.1 4.2 4.3 4.1 要求 造轮子 -- stack 建立 stack.h 和 stack.cpp 编写 stack.cpp 函数练习操作 Stack 的所有公开接口并加以编译执行 在 stack.h 中定义 push(), pop(), peek()等函数 在 stack.cpp 中运用 Stack 类提供的接口从标准输入设备依次读入一些字符串并将它们 push 到 stack 中直到读到文件末尾 EOF或是 stack 已满 代码 stack.h #ifndef STACK_H_INCLUDED #define STACK_H_INCLUDED#includeiostream #includestring #includevector #includealgorithm using namespace std;class Stack { public:bool push( const string ); // 声明 push 函数将字符串压入栈中bool pop( string elem ); // 声明 pop 函数从栈中弹出字符串bool peek( string elem ); // 声明 peek 函数获取栈顶元素bool empty() const { return _stack.empty(); } // 判断栈是否为空bool full() const { return _stack.size() _stack.max_size(); } // 判断栈是否已满int size() const { return _stack.size(); } // 获取栈中元素的数量private:vectorstring _stack; // 栈的存储结构使用 vector 实现 };bool Stack::push( const string elem ) {if ( full() ) return false; // 如果栈已满返回 false_stack.push_back( elem ); // 向栈中添加元素return true; }bool Stack::peek( string elem ) {if ( empty() ) return false; // 如果栈为空返回 falseelem _stack.back(); // 获取栈顶元素return true; }bool Stack::pop( string elem ) {if ( empty() ) return false; // 如果栈为空返回 falseelem _stack.back(); // 获取栈顶元素_stack.pop_back(); // 弹出栈顶元素return true; }#endif // STACK_H_INCLUDED stack.cpp // stack.cpp#includeiostream #includestring #include stack.h using namespace std;int main() {Stack st; // 创建一个 Stack 对象string str;while ( cin str !st.full() ) // 当用户输入字符串且栈未满时循环执行st.push( str ); // 将读取的字符串压入栈中if (st.empty()) { // 如果栈为空则输出提示信息并返回 0cout \n no strings were read!\n;return 0;}st.peek (str); // 获取栈顶元素保存在 str 中if (st.size() 1 str.empty()) { // 如果栈中只有一个元素且栈顶元素为空字符串则输出提示信息并返回 0cout \n no strings were read\n;return 0;}cout \n Read in st.size() strings!\n The strings, in reverse order: \n; // 输出读取的字符串总数和反序排列后的提示信息while (st.size()) // 当栈不为空时循环执行if (st.pop(str)) // 从栈中弹出字符串并输出cout str ;cout \n There are now st.size() elements in the stack!\n; // 输出栈中剩余元素的数量return 0; }输入输出 输入完后换行ctrl Z表示 EOFLinux就ctrl D A way a lone a last a loves a long the ^ZRead in 11 strings! The strings, in reverse order: the long a loves a last a lone a way A There are now 0 elements in the stack! 4.2 坑 count()函数的类内声明和类外实现注意不要写成 bool否则只会返回 occurs 1 times 要求 扩展 Stack 功能以支持 find() 和 count() 两个操作 find() 会查看某值是否存在而返回 true 或 false count() 返回某字符串出现次数 重新实现 4.1 的 .cpp让它调用这2个函数 以同名的泛型算法来实现这两个函数 为了调用2个泛型算法需要 global scope全局作用域运算符 ::  解释 ::count() 表示调用全局命名空间中的 count() 函数而不是 Stack 类中定义的同名函数。在这种情况下:: 作为区分局部函数和全局函数的作用域限定符可以指定使用全局命名空间中的函数。如果没有加上 ::则编译器会根据它找到的第一个同名函数进行调用这可能会导致意料之外的结果 代码 stack.h #ifndef STACK_H_INCLUDED #define STACK_H_INCLUDED#includeiostream #includestring #includevector #includealgorithm using namespace std;class Stack { public:bool push( const string ); // 声明 push 函数将字符串压入栈中bool pop( string elem ); // 声明 pop 函数从栈中弹出字符串bool peek( string elem ); // 声明 peek 函数获取栈顶元素bool empty() const { return _stack.empty(); } // 判断栈是否为空bool full() const { return _stack.size() _stack.max_size(); } // 判断栈是否已满int size() const { return _stack.size(); } // 获取栈中元素的数量// 4.2 拓展bool find( const string elem ) const;int count( const string elem ) const;private:vectorstring _stack; // 栈的存储结构使用 vector 实现 };bool Stack::push( const string elem ) {if ( full() ) return false; // 如果栈已满返回 false_stack.push_back( elem ); // 向栈中添加元素return true; }bool Stack::peek( string elem ) {if ( empty() ) return false; // 如果栈为空返回 falseelem _stack.back(); // 获取栈顶元素return true; }bool Stack::pop( string elem ) {if ( empty() ) return false; // 如果栈为空返回 falseelem _stack.back(); // 获取栈顶元素_stack.pop_back(); // 弹出栈顶元素return true; }// 4.2 拓展 bool Stack::find( const string elem ) const {vectorstring::const_iterator end_it _stack.end();return ::find(_stack.begin(), end_it, elem ) ! end_it; // 全局作用域 :: }int Stack::count( const string elem ) const {return ::count(_stack.begin(), _stack.end(), elem ); }#endif // STACK_H_INCLUDED stack.cpp // stack.cpp#includeiostream #includestring #include stack.h using namespace std;int main() {Stack st; // 创建一个 Stack 对象string str;while ( cin str !st.full() ) // 当用户输入字符串且栈未满时循环执行st.push( str ); // 将读取的字符串压入栈中if (st.empty()) { // 如果栈为空则输出提示信息并返回 0cout \n no strings were read!\n;return 0;}st.peek (str); // 获取栈顶元素保存在 str 中if (st.size() 1 str.empty()) { // 如果栈中只有一个元素且栈顶元素为空字符串则输出提示信息并返回 0cout \n no strings were read\n;return 0;}cout \n Read in st.size() strings!\n;cin.clear(); // 清除 end-of-file 设定cout what word to search for? ;cin str;bool found st.find(str);int count found ? st.count(str) : 0;cout str ( found ? is : isn\t ) in the stack. ;if (found)cout It occurs count times\n;return 0; }输入输出 A way a lone a last a loved a long the ^ZRead in 11 strings! what word to search for? a a is in the stack. It occurs 4 times 4.3 #include string using namespace std;// 定义一个全局封装类 globalWrapper class globalWrapper { public:// (静态成员函数)返回测试通过的数量 static int tests_passed() { return _tests_passed; }// 返回已运行的测试数量 static int tests_run() { return _tests_run; }// 返回版本号 static int version_number() { return _version_number; }// 返回版本时间戳 static string version_stamp() { return _version_stamp; }// 返回程序名称 static string program_name() { return _program_name; }// 设置测试通过的数量 static void tests_passed(int nval) { _tests_passed nval; }// 设置已运行的测试数量 static void tests_run(int nval) { _tests_run nval; }// (静态成员函数)设置版本号 static void version_number(int nval) { _version_number nval; }// 设置版本时间戳 static void version_stamp(const string nstamp) { _version_stamp nstamp; }// 设置程序名称 static void program_name(const string npn) { _program_name npn; }private:static string _program_name; // (静态成员变量)存储程序名称 static string _version_stamp; // 存储版本时间戳 static int _version_number; // 存储版本号 static int _tests_run; // 存储已运行的测试数量 static int _tests_passed; // 存储测试通过的数量 };string globalWrapper::_program_name; // 初始化静态成员变量 _program_name string globalWrapper::_version_stamp; int globalWrapper::_version_number; int globalWrapper::_tests_run; // 初始化静态成员变量 _tests_run int globalWrapper::_tests_passed;
http://wiki.neutronadmin.com/news/363108/

相关文章:

  • 柳州网站建设招聘百度招聘
  • 电子商务网站制作公司1688一件代发详细步骤
  • 网站页面设计服务网站构建建设案例展示
  • wordpress写了文章打不开长沙网站seo技术
  • 免费1级做爰网站怎么通过互联网做一个服务的网站
  • 我想自己建个网站 应该怎么做360的网站怎么做
  • 九江县网站建设代运营公司是怎么运营的
  • 物流公司网站建设模板站长工具收录
  • 网站制作多少页长春到四平
  • 公司 做网站短视频制作自学教程
  • 国家电网网站制作百度站长对网站会有影响吗
  • 东莞高端网站设计百度产品推广
  • 包装策划与设计专业南京seo推广优化
  • 模板网站和插件有哪些网络组网方案
  • icp网站备案查询自助建站系统源源码
  • 微信平台微网站开发qq空间钓鱼网站制作
  • 上海企业网站建设方法通辽公司做网站
  • 巴中企业网站建设wordpress报价计算器
  • 网站定制分享网站建设的培训班
  • 关于网站建设的合同协议成都发布最新消息
  • wordpress搭建教育网站网站建设人才招聘
  • 网站建设与管理读后感企业响应网站
  • 网站外链建设书籍做相册集什么网站
  • 佛山模板建站哪家好html5电影网站源码php
  • 企业网站seowordpress设置上传大小
  • 网站建设方案策划网页文档
  • 织梦网站建设过程做的好的商城网站设计
  • 网站建设创新成果广东建设工程信息网站
  • 免费做网站电话不用登录的秒玩小游戏
  • 电子商务网站规划与建设步骤网站建设企业有哪些内容