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

成都网站建设蜀美网络协会网站建设计划书

成都网站建设蜀美网络,协会网站建设计划书,抖音seo怎么做的,搜索引擎优化的内容包括https://blog.csdn.net/yanxiaolx/article/details/52235212题目#xff1a;请实现一个函数#xff0c;把字符串中的每个空格替换成“%20”。例如输入“We are happy.”#xff0c;则输出“We%20are%20happy.”。解析#xff1a;时间复杂度为O(n)的解法。完整代码及测试用例…https://blog.csdn.net/yanxiaolx/article/details/52235212题目请实现一个函数把字符串中的每个空格替换成“%20”。例如输入“We are happy.”则输出“We%20are%20happy.”。解析时间复杂度为O(n)的解法。完整代码及测试用例实现[cpp] view plaincopy#includeiostream  using namespace std;  #include cstring    //length 为字符数组string的总容量  void ReplaceBlank(char string[], int length)  {      if (string  NULLlength  0)      {          return;      }      //reallyLength 为字符串string的实际长度      int reallyLength  0, numberOfBlank  0,i0;            while (string[i]!\0)      {          reallyLength;            if (string[i]   )          {              numberOfBlank;          }          i;      }        //newLength 为把空格替换成%20之后的长度      int newLength  reallyLength  numberOfBlank * 2;      if (newLength  length)      {          return;      }        int indexOfReally  reallyLength;      int indexOfNew  newLength;      while (indexOfReally  0  indexOfNew indexOfReally)      {          if (string[indexOfReally]   )          {              string[indexOfNew--]  0;              string[indexOfNew--]  2;              string[indexOfNew--]  %;          }          else          {              string[indexOfNew--]  string[indexOfReally];          }            --indexOfReally;      }  }      // 测试代码  void Test(char* testName, char string[], int length, char expected[])  {      if (testName ! NULL)      {          cout  testName   begins: ;      }        ReplaceBlank(string, length);        if (expected  NULL  string  NULL)      {          cout  passed.  endl;      }      else if (expected  NULL  string ! NULL)      {          cout  failed.  endl;      }      else if (strcmp(string, expected)  0)      {          cout  passed.  endl;      }      else      {          cout  failed.  endl;      }  }      void Test1()  {      // 空格在句子中间      const int length  100;        char string[length]  we are happy.;      Test(Test1, string, length, we%20are%20happy.);  }      void Test2()  {      // 空格在句子开头      const int length  100;        char string[length]   wearehappy.;      Test(Test2, string, length, %20wearehappy.);  }    void Test3()  {      // 空格在句子末尾      const int length  100;        char string[length]  wearehappy. ;      Test(Test3, string, length, wearehappy.%20);  }    void Test4()  {      // 连续有两个空格      const int length  100;        char string[length]  we  are happy.;      Test(Test4, string, length, we%20%20are%20happy.);  }    void Test5()  {      // 传入NULL      Test(Test5, NULL, 0, NULL);  }    void Test6()  {      // 传入内容为空的字符串      const int length  100;        char string[length]  ;      Test(Test6, string, length, );  }    void Test7()  {      //传入内容为一个空格的字符串      const int length  100;        char string[length]   ;      Test(Test7, string, length, %20);  }    void Test8()  {      // 传入的字符串没有空格      const int length  100;        char string[length]  wearehappy.;      Test(Test8, string, length, wearehappy.);  }    void Test9()  {      // 传入的字符串全是空格      const int length  100;        char string[length]     ;      Test(Test9, string, length, %20%20%20);  }    int main()  {      Test1();      Test2();      Test3();      Test4();      Test5();      Test6();      Test7();      Test8();      Test9();        system(pause);       return 0;  }  运行结果 Test1 begins: passed. Test2 begins: passed. Test3 begins: passed. Test4 begins: passed. Test5 begins: passed. Test6 begins: passed. Test7 begins: passed. Test8 begins: passed. Test9 begins: passed. 请按任意键继续. . .
http://www.yutouwan.com/news/218626/

相关文章:

  • 做k12网站建设动漫网站的目的
  • 深圳有做网站的公司闵行广州网站建设公司
  • 浅谈电子商务网站建设网站建设在什么税控盘
  • 凡客诚品官方网站的代码wordpress防止并发数
  • 邢台网站制作深圳电商网站建设公司
  • 苏州网站建设代理江苏城乡建设职业学院就业网站
  • 中国城乡与建设部网站苏州网站关键词优化
  • wordpress 导航网站模板品牌推广案例
  • 个人网站建设作用自己建设房源网站
  • 网站业务怎么做的h5网站是什么意思
  • 导航网站教程wordpress 文章标签
  • 用wordpress建站要不要用宝塔服装业网站建设的策划
  • 建设购物网站需要多少费用公司做的网站费用如何做账
  • 网站首页模板设计图济宁网络
  • 厦门人才网官方网站请解释网站开发的主要流程
  • 新建网站站点的微信公众号链接网站开发
  • 河津网站制作网站商城微信支付接口
  • 网站建设需求文件国内做的好的电商网站有哪些
  • 哪个网站有学做吃的什么是设计方案
  • 深圳网站建设 贴吧家用电脑网站建设
  • 建设银行官方网站地址微信投放广告多少钱
  • 和平东路网站建设建设工程+质量+协会网站
  • h5建站工具网页制作教程视频简单
  • 2017网站建设报价单免费做网站推荐
  • 徐州网站建设培训千图网素材下载网站
  • 天天爱天天做视频网站做网站 什么主题较好
  • 建设网站火车票预订做网站 商标分类
  • 网站开发关于安全问题app制作手机版
  • 网站的在线支付模块怎么做电商网站建设代理商
  • 浙江网站建设电话wordpress admin-ajax.php远程sql注入漏洞