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;
}
运行结果显示如下:
相关推荐
传奇开心果编程16 分钟前
【Rust入门知识点学与练】第21课:Trait 进阶 Advanced Traits
开发语言·学习·rust
新时代牛马25 分钟前
字符设备驱动完整篇:从 cdev_add、file_operations 到chrdev_open 与排障
开发语言·python
swordbob28 分钟前
ReentrantLock 与 AQS 完整学习手册
java·开发语言
政企项目老覃1 小时前
大模型幻觉治理与自动评测:金融风控场景的落地实践
人工智能·算法·机器学习
淡海水1 小时前
08-03-不可变-ImmutableDictionary-TKey-TValue-与ImmutableHashSet-T-持久化哈希树
数据结构·算法·c#·哈希算法·dictionary·immutable
白山编程大哥1 小时前
Java OutputStreamWriter 详解:从字符到字节的桥梁
java·开发语言·python
hansang_IR1 小时前
【题解】[APIO2023] 赛博乐园 / cyberland
c++·算法·图论
洛阳纸贵2 小时前
MATLAB-matlab基础知识
学习·算法·matlab
落羽的落羽2 小时前
【AI】快速理解AI应用的相关名词概念
linux·c++·人工智能·python·计算机网络·算法