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;
}
运行结果显示如下:
相关推荐
“AI国潮设计-小江”3 小时前
【AIGC实战】Python+SDXL批量生成“潮汕英歌舞不倒翁”IP | 角色一致性与多场景融合方案,附完整代码
开发语言·人工智能·python·prompt·aigc
传奇开心果编程3 小时前
【Rust入门练中学】第6课:结构体与方法
开发语言·rust·结构体·编程语言理论·结构体方法·编程通用语言
code tsunami3 小时前
【无标题】
开发语言·python
春弦_3 小时前
自用算法整理二
数据结构·算法·图论
CodeGL4 小时前
10、Python基础之进程和线程
开发语言·python
hetao17338374 小时前
2026-10-22~23 hetao1733837 的刷题记录
c++·算法
TechWayfarer5 小时前
PHP漏洞被利用,怎么揪出攻击IP?
开发语言·python·tcp/ip·网络安全·php
java_nnnn5 小时前
LeetCode刷题滑动窗口(串联所有单词的子串+最小覆盖的子串)Java
算法·leetcode·职场和发展
王老师青少年编程5 小时前
2025年6月GESP真题及题解(C++三级): 选择题和判断题(题解)
c++·真题·gesp·答案·csp·三级·信奥赛
Navigator_Z5 小时前
LeetCode //C - 1301. Number of Paths with Max Score
c语言·算法·leetcode