C++ //练习 17.2 定义一个tuple,保存一个string、一个vector<string>和一个pair<string, int>。

C++ Primer(第5版) 练习 17.2

练习 17.2 定义一个tuple,保存一个string、一个vector和一个pair<string, int>。

环境:Linux Ubuntu(云服务器)
工具:vim
代码块
cpp 复制代码
/*************************************************************************
	> File Name: ex17.2.cpp
	> Author: 
	> Mail: 
	> Created Time: Fri 16 Aug 2024 08:48:44 AM CST
 ************************************************************************/

#include<iostream>
#include<tuple>
#include<vector>
using namespace std;

int main(){
    tuple<string, vector<string>, pair<string, int>> t("print", {"Hello", " World"}, {" program", 2});
    cout<<get<0>(t)<<" ";
    for(const auto &s : get<1>(t)){
        cout<<s;
    }
    cout<<get<2>(t).first<<" "<<get<2>(t).second<<endl;

    return 0;
}
运行结果显示如下:
相关推荐
半桶水专家1 天前
go语言中的结构体嵌入详解
开发语言·后端·golang
长安er1 天前
LeetCode215/347/295 堆相关理论与题目
java·数据结构·算法·leetcode·
元亓亓亓1 天前
LeetCode热题100--62. 不同路径--中等
算法·leetcode·职场和发展
在屏幕前出油1 天前
二、Python面向对象编程基础——理解self
开发语言·python
小白菜又菜1 天前
Leetcode 1925. Count Square Sum Triples
算法·leetcode
粉红色回忆1 天前
用链表实现了简单版本的malloc/free函数
数据结构·c++
阿方索1 天前
python文件与数据格式化
开发语言·python
登山人在路上1 天前
Nginx三种会话保持算法对比
算法·哈希算法·散列表
写代码的小球1 天前
C++计算器(学生版)
c++·算法
AI科技星1 天前
张祥前统一场论宇宙大统一方程的求导验证
服务器·人工智能·科技·线性代数·算法·生活