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

购物商场网站开发过程详细说明seo营销论文

购物商场网站开发过程详细说明,seo营销论文,设计说明怎么写范文,企业的漏沟设计公司阅读导航 字符串处理类一、stoi()(将字符串转换为整数类型)二、to_string()(将整数类型转换为字符串类型)三、stringstream函数(将一个字符串按照指定的分隔符进行分词) 字符串处理类 一、stoi()&#xff…

在这里插入图片描述

阅读导航

  • 字符串处理类
    • 一、stoi()(将字符串转换为整数类型)
    • 二、to_string()(将整数类型转换为字符串类型)
    • 三、stringstream函数(将一个字符串按照指定的分隔符进行分词)

字符串处理类

一、stoi()(将字符串转换为整数类型)

在C++中,可以使用 std::stoi() 函数将字符串转换为整数类型。

示例代码如下:

#include <iostream>
#include <string>int main() {std::string str = "12345";int num = std::stoi(str);std::cout << "The converted integer is: " << num << std::endl;return 0;
}

输出结果为:

The converted integer is: 12345

std::stoi() 函数接受一个字符串作为参数,并尝试将其转换为整数类型。如果转换成功,则返回转换后的整数值;如果无法进行有效的转换,将抛出 std::invalid_argumentstd::out_of_range 异常。

需要注意的是,如果字符串中包含除数字以外的字符,或者超出了整数类型的取值范围,那么转换将失败。在使用 std::stoi() 函数时,要确保输入的字符串符合期望的格式和范围,或者进行适当的异常处理。

二、to_string()(将整数类型转换为字符串类型)

在C++中,可以使用 std::to_string() 函数将整数类型转换为字符串类型。

示例代码如下:

#include <iostream>
#include <string>int main() {int num = 12345;std::string str = std::to_string(num);std::cout << "The converted string is: " << str << std::endl;return 0;
}

输出结果为:

The converted string is: 12345

std::to_string() 函数接受一个整数作为参数,并返回对应的字符串表示。它将整数转换为相应的十进制字符串。

需要注意的是,转换后的字符串对象是一个新的副本,原始的整数值并不受影响。

另外,如果需要将其他类型的值转换为字符串,也可以借助字符串流(std::stringstream)和输出流操作符来实现。例如:

#include <iostream>
#include <string>
#include <sstream>int main() {int num = 12345;std::stringstream ss;ss << num;std::string str = ss.str();std::cout << "The converted string is: " << str << std::endl;return 0;
}

这种方法可用于将各种类型(如浮点数、布尔值等)转换为字符串。

三、stringstream函数(将一个字符串按照指定的分隔符进行分词)

stringstream 是 C++ 标准库中的一个类,它可以将字符串转换为流,从而可以方便地对字符串进行输入输出操作,如分词、格式化等

通过 stringstream,我们可以将一个字符串按照指定的分隔符进行分词。具体使用方法如下:

  1. 首先需要包含头文件 :

    #include <sstream>
    
  2. 然后创建一个 stringstream 对象,并将需要分词的字符串传入该对象的构造函数:

    std::stringstream ss("this is a string");
    
  3. 使用 while 循环和 >> 运算符,从 stringstream 中逐个读取分词:

    std::string word;
    while (ss >> word) {// 处理分词
    }
    

    在此代码片段中,每次循环会从 stringstream 中读取一个单词(以空格为分隔符),并将其存储在变量 word 中。

    可以将 >> 运算符看作是一个提取器,它会从 stringstream 中读取下一个可用的值,并将其存储到变量中。当所有的值都被读取完毕时,>> 运算符会返回 false,此时循环会退出。

    可以使用 getline() 函数来按照指定的分隔符读取一整行数据,例如:

    std::string line;
    getline(ss, line, ','); // 以逗号为分隔符读取一整行数据
    

如果你需要对字符串进行分词、格式化等操作,stringstream 可以是一个很好的工具。

力扣题目:2512. 奖励最顶尖的 K 名学生
解题代码:

class Solution {
public:vector<int> topStudents(vector<string>& positive_feedback, vector<string>& negative_feedback, vector<string>& report, vector<int>& student_id, int k) {map<std::string, int> words;for (const auto& word : positive_feedback) {words[word] = 3;}for (const auto& word : negative_feedback) {words[word] = -1;}vector<vector<int>> A;for (int i = 0; i < report.size(); i++) {stringstream ss;string w;int score = 0;ss << report[i];while (ss >> w) {if (words.count(w)) {score += words[w];}}A.push_back({-score, student_id[i]});}sort(A.begin(), A.end());vector<int> top_k;for (int i = 0; i < k; i++) {top_k.push_back(A[i][1]);}return top_k;}
};

文章转载自:
http://www.morning.fblkr.cn.gov.cn.fblkr.cn
http://www.morning.xcnwf.cn.gov.cn.xcnwf.cn
http://www.morning.splcc.cn.gov.cn.splcc.cn
http://www.morning.ykgp.cn.gov.cn.ykgp.cn
http://www.morning.flxgx.cn.gov.cn.flxgx.cn
http://www.morning.pfmsh.cn.gov.cn.pfmsh.cn
http://www.morning.snbq.cn.gov.cn.snbq.cn
http://www.morning.tfwr.cn.gov.cn.tfwr.cn
http://www.morning.hcszr.cn.gov.cn.hcszr.cn
http://www.morning.cdrzw.cn.gov.cn.cdrzw.cn
http://www.morning.mxftp.com.gov.cn.mxftp.com
http://www.morning.guangda11.cn.gov.cn.guangda11.cn
http://www.morning.mkzdp.cn.gov.cn.mkzdp.cn
http://www.morning.hpkr.cn.gov.cn.hpkr.cn
http://www.morning.fpkpz.cn.gov.cn.fpkpz.cn
http://www.morning.dnwlb.cn.gov.cn.dnwlb.cn
http://www.morning.pghfy.cn.gov.cn.pghfy.cn
http://www.morning.bbyqz.cn.gov.cn.bbyqz.cn
http://www.morning.fwnyz.cn.gov.cn.fwnyz.cn
http://www.morning.gcqkb.cn.gov.cn.gcqkb.cn
http://www.morning.mnrqq.cn.gov.cn.mnrqq.cn
http://www.morning.ptmch.com.gov.cn.ptmch.com
http://www.morning.knqzd.cn.gov.cn.knqzd.cn
http://www.morning.jrkzk.cn.gov.cn.jrkzk.cn
http://www.morning.ryzgp.cn.gov.cn.ryzgp.cn
http://www.morning.xwgbr.cn.gov.cn.xwgbr.cn
http://www.morning.qwpyf.cn.gov.cn.qwpyf.cn
http://www.morning.xpwdf.cn.gov.cn.xpwdf.cn
http://www.morning.hxhrg.cn.gov.cn.hxhrg.cn
http://www.morning.zhishizf.cn.gov.cn.zhishizf.cn
http://www.morning.khtjn.cn.gov.cn.khtjn.cn
http://www.morning.bnrnb.cn.gov.cn.bnrnb.cn
http://www.morning.qsdnt.cn.gov.cn.qsdnt.cn
http://www.morning.fqssx.cn.gov.cn.fqssx.cn
http://www.morning.kkdbz.cn.gov.cn.kkdbz.cn
http://www.morning.sqtsl.cn.gov.cn.sqtsl.cn
http://www.morning.pnmtk.cn.gov.cn.pnmtk.cn
http://www.morning.tpyjr.cn.gov.cn.tpyjr.cn
http://www.morning.slfmp.cn.gov.cn.slfmp.cn
http://www.morning.htqrh.cn.gov.cn.htqrh.cn
http://www.morning.lhytw.cn.gov.cn.lhytw.cn
http://www.morning.nlbw.cn.gov.cn.nlbw.cn
http://www.morning.rxhsm.cn.gov.cn.rxhsm.cn
http://www.morning.gslz.com.cn.gov.cn.gslz.com.cn
http://www.morning.fnxzk.cn.gov.cn.fnxzk.cn
http://www.morning.tqbyw.cn.gov.cn.tqbyw.cn
http://www.morning.xxgfl.cn.gov.cn.xxgfl.cn
http://www.morning.ytfr.cn.gov.cn.ytfr.cn
http://www.morning.nlgnk.cn.gov.cn.nlgnk.cn
http://www.morning.fthcn.cn.gov.cn.fthcn.cn
http://www.morning.qmxsx.cn.gov.cn.qmxsx.cn
http://www.morning.gbrdx.cn.gov.cn.gbrdx.cn
http://www.morning.kehejia.com.gov.cn.kehejia.com
http://www.morning.kttbx.cn.gov.cn.kttbx.cn
http://www.morning.kehejia.com.gov.cn.kehejia.com
http://www.morning.yrjym.cn.gov.cn.yrjym.cn
http://www.morning.ppgdp.cn.gov.cn.ppgdp.cn
http://www.morning.rbqlw.cn.gov.cn.rbqlw.cn
http://www.morning.jwtwf.cn.gov.cn.jwtwf.cn
http://www.morning.fldk.cn.gov.cn.fldk.cn
http://www.morning.bnxfj.cn.gov.cn.bnxfj.cn
http://www.morning.pjrgb.cn.gov.cn.pjrgb.cn
http://www.morning.807yy.cn.gov.cn.807yy.cn
http://www.morning.ptwqf.cn.gov.cn.ptwqf.cn
http://www.morning.jfch.cn.gov.cn.jfch.cn
http://www.morning.gjlml.cn.gov.cn.gjlml.cn
http://www.morning.yrhpg.cn.gov.cn.yrhpg.cn
http://www.morning.xqffq.cn.gov.cn.xqffq.cn
http://www.morning.ggqcg.cn.gov.cn.ggqcg.cn
http://www.morning.lkthj.cn.gov.cn.lkthj.cn
http://www.morning.rgnp.cn.gov.cn.rgnp.cn
http://www.morning.zfgh.cn.gov.cn.zfgh.cn
http://www.morning.lfmwt.cn.gov.cn.lfmwt.cn
http://www.morning.knrgb.cn.gov.cn.knrgb.cn
http://www.morning.pplxd.cn.gov.cn.pplxd.cn
http://www.morning.mqdr.cn.gov.cn.mqdr.cn
http://www.morning.sxlrg.cn.gov.cn.sxlrg.cn
http://www.morning.tnwgc.cn.gov.cn.tnwgc.cn
http://www.morning.jmbfx.cn.gov.cn.jmbfx.cn
http://www.morning.ktpzb.cn.gov.cn.ktpzb.cn
http://www.tj-hxxt.cn/news/15.html

相关文章:

  • 找工作哪个网站好招聘信息营销型网站建设ppt
  • 运城 网站建设个人网站设计欣赏
  • 巫山网站设计中国搜索引擎
  • 网站建设有哪些步骤网络营销推广渠道
  • 如何用自己电脑做网站服务器网站seo优化徐州百度网络
  • 快递公司网站模板搜索app下载
  • 自己做网站才是互联网网站seo哪家公司好
  • 网站开发公司地址如何关闭2345网址导航
  • 政府网站建设理念宝塔建站系统
  • 网站建设与管理自考重点佛山网站优化软件
  • 网站服务器购买价格百度统计app