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

为企业做出贡献的句子seo流量增加软件

为企业做出贡献的句子,seo流量增加软件,网站续费通知单,哪个建设网站公司好在 C 中&#xff0c;数据结构之间的嵌套是非常常见的&#xff0c;尤其是在处理复杂数据时。以下是几种最常用的数据结构嵌套方式及其典型应用场景的总结&#xff1a; 1. std::vector 嵌套 std::vector 定义&#xff1a;std::vector<std::vector<T>>。用途&#xf…

  在 C++ 中,数据结构之间的嵌套是非常常见的,尤其是在处理复杂数据时。以下是几种最常用的数据结构嵌套方式及其典型应用场景的总结:


1. std::vector 嵌套 std::vector

  • 定义std::vector<std::vector<T>>
  • 用途:表示二维数组或矩阵。
  • 示例
    #include <iostream>
    #include <vector>int main() {std::vector<std::vector<int>> matrix = {{1, 2, 3},{4, 5, 6},{7, 8, 9}};// 遍历二维 vectorfor (const auto& row : matrix) {for (int value : row) {std::cout << value << " ";}std::cout << std::endl;}return 0;
    }
    
  • 输出
    1 2 3 
    4 5 6 
    7 8 9 
    

2. std::map 嵌套 std::vector

  • 定义std::map<Key, std::vector<T>>
  • 用途:表示键到一组值的映射(例如,一个班级中每个学生的成绩列表)。
  • 示例
    #include <iostream>
    #include <map>
    #include <vector>int main() {std::map<std::string, std::vector<int>> studentGrades = {{"Alice", {90, 85, 88}},{"Bob", {78, 82, 80}},{"Charlie", {95, 91, 89}}};// 遍历 map 中的 vectorfor (const auto& [name, grades] : studentGrades) {std::cout << name << ": ";for (int grade : grades) {std::cout << grade << " ";}std::cout << std::endl;}return 0;
    }
    
  • 输出
    Alice: 90 85 88 
    Bob: 78 82 80 
    Charlie: 95 91 89 
    

3. std::vector 嵌套 std::map

  • 定义std::vector<std::map<Key, Value>>
  • 用途:表示一组键值对集合(例如,多个学生的属性集合)。
  • 示例
    #include <iostream>
    #include <vector>
    #include <map>int main() {std::vector<std::map<std::string, std::string>> students = {{{"name", "Alice"}, {"age", "20"}},{{"name", "Bob"}, {"age", "21"}},{{"name", "Charlie"}, {"age", "22"}}};// 遍历 vector 中的 mapfor (const auto& student : students) {for (const auto& [key, value] : student) {std::cout << key << ": " << value << " ";}std::cout << std::endl;}return 0;
    }
    
  • 输出
    name: Alice age: 20 
    name: Bob age: 21 
    name: Charlie age: 22 
    

4. std::map 嵌套 std::map

  • 定义std::map<Key1, std::map<Key2, Value>>
  • 用途:表示多层键值对映射(例如,城市到区域到人口数量的映射)。
  • 示例
    #include <iostream>
    #include <map>int main() {std::map<std::string, std::map<std::string, int>> cityPopulation = {{"New York", {{"Manhattan", 1600000}, {"Brooklyn", 2600000}}},{"Los Angeles", {{"Downtown", 500000}, {"Hollywood", 200000}}}};// 遍历嵌套的 mapfor (const auto& [city, areas] : cityPopulation) {std::cout << city << ":\n";for (const auto& [area, population] : areas) {std::cout << "  " << area << ": " << population << "\n";}}return 0;
    }
    
  • 输出
    New York:Manhattan: 1600000Brooklyn: 2600000
    Los Angeles:Downtown: 500000Hollywood: 200000
    

5. std::vector 嵌套 std::pair

  • 定义std::vector<std::pair<T1, T2>>
  • 用途:表示一组键值对(例如,存储多个学生的姓名和年龄)。
  • 示例
    #include <iostream>
    #include <vector>
    #include <utility>  // 包含 std::pairint main() {std::vector<std::pair<std::string, int>> students = {{"Alice", 20},{"Bob", 21},{"Charlie", 22}};// 遍历 vector 中的 pairfor (const auto& [name, age] : students) {std::cout << name << ": " << age << std::endl;}return 0;
    }
    
  • 输出
    Alice: 20
    Bob: 21
    Charlie: 22
    

6. std::map 嵌套 std::pair

  • 定义std::map<Key, std::pair<T1, T2>>
  • 用途:表示键到一对值的映射(例如,学生姓名到年龄和成绩的映射)。
  • 示例
    #include <iostream>
    #include <map>
    #include <utility>  // 包含 std::pairint main() {std::map<std::string, std::pair<int, int>> studentInfo = {{"Alice", {20, 90}},{"Bob", {21, 85}},{"Charlie", {22, 95}}};// 遍历 map 中的 pairfor (const auto& [name, info] : studentInfo) {std::cout << name << ": Age = " << info.first << ", Grade = " << info.second << std::endl;}return 0;
    }
    
  • 输出
    Alice: Age = 20, Grade = 90
    Bob: Age = 21, Grade = 85
    Charlie: Age = 22, Grade = 95
    

7. std::set 嵌套 std::vector

  • 定义std::set<std::vector<T>>
  • 用途:表示一组唯一的向量(例如,存储唯一的路径或组合)。
  • 示例
    #include <iostream>
    #include <set>
    #include <vector>int main() {std::set<std::vector<int>> uniqueVectors = {{1, 2, 3},{4, 5, 6},{1, 2, 3}  // 重复,不会被插入};// 遍历 set 中的 vectorfor (const auto& vec : uniqueVectors) {for (int value : vec) {std::cout << value << " ";}std::cout << std::endl;}return 0;
    }
    
  • 输出
    1 2 3 
    4 5 6 
    

总结

  • std::vector 嵌套 std::vector:表示二维数组或矩阵。
  • std::map 嵌套 std::vector:表示键到一组值的映射。
  • std::vector 嵌套 std::map:表示一组键值对集合。
  • std::map 嵌套 std::map:表示多层键值对映射。
  • std::vector 嵌套 std::pair:表示一组键值对。
  • std::map 嵌套 std::pair:表示键到一对值的映射。
  • std::set 嵌套 std::vector:表示一组唯一的向量。
http://www.dtcms.com/wzjs/415118.html

相关文章:

  • 做国际网站找阿里赣州seo唐三
  • 大同市建设工程招标投标网站关键词汇总
  • 电子商务推广怎么做seo网络推广培训班
  • 网站建设与开发做什么理发美发培训学校
  • 做地方门户网站的排名中视频自媒体账号注册下载
  • 郴州做网站nba交易最新消息汇总
  • 网站开发建设与维护目前搜索引擎排名
  • 微信起诉小程序叫什么网站seo方法
  • 宝鸡市建设工程质量安全监督站网站排名优化关键词
  • 自己可以做公司网站吗百度网盘链接
  • 网站没有备案怎么做支付谷歌优化师
  • 建网站的软件优帮云北京互联网营销公司
  • 服务器ip做网站acca少女网课视频
  • 专业app开发制作公司seo网络优化前景怎么样
  • 南昌网站开发机构百度本地推广
  • 知乎 做网站的公司 中企动力无锡谷歌推广
  • 城阳区城市规划建设局网站百度指数移动版怎么用
  • 自己做网站生意怎么样ip营销的概念
  • 云南网站建设首选公司企业策划书
  • 怎么自建一个网站百度一下首页手机版
  • 网站开发论文摘要整站seo定制
  • 如何做视频教程网站百度收录刷排名
  • 做调查的有哪些网站有哪些智慧软文发稿平台官网
  • 网站建设通报营销方案设计思路
  • 丹阳火车站片区规划整站排名服务
  • 国外家居设计网站十大成功营销策划案例
  • 做网站page关键词代做排名推广
  • 网站和app设计区别网络营销环境分析包括哪些内容
  • 郑州建站推广公司怎么在百度做宣传广告
  • 新建网站求友链平台企业网络规划与设计