C++课后习题训练记录Day44

1.练习项目:

输入一个整数 nn 个数字,然后按字典序升序输出这 n 个数字的所有全排列

2.选择课程

在蓝桥云课中选择课程《16届蓝桥杯省赛无忧班(C&C++ 组)4期》,选择第STL"课程10并开始练习。

3.开始练习

(1)源码:

#include <iostream>

#include <utility>

#include <vector>

struct Person {

std::string name;

int age;

};

int main() {

std::vector<Person> people;

people.push_back({"Alice", 25});

people.push_back({"Bob", 30});

people.push_back({"Charlie", 20});

std::vector<std::pair<Person, int>> scores;

scores.push_back({people[0], 90});

scores.push_back({people[1], 85});

scores.push_back({people[2], 95});

for (const auto& pair : scores) {

std::cout << "Name: " << pair.first.name << std::endl;

std::cout << "Age: " << pair.first.age << std::endl;

std::cout << "Score: " << pair.second << std::endl;

std::cout << std::endl;

}

return 0;

}

(2)检验结果

对此代码进行检验,检验后无报错,提交此代码,判题结果为正确100分。

(3)练习心得:注意每段代码末尾的分号是否存在,如不存在则需即使补充;输入法是否切换为英语模式;语法是否错误。

相关推荐
blasit13 小时前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
肆忆_2 天前
# 用 5 个问题学懂 C++ 虚函数(入门级)
c++
不想写代码的星星2 天前
虚函数表:C++ 多态背后的那个男人
c++
端平入洛4 天前
delete又未完全delete
c++
端平入洛5 天前
auto有时不auto
c++
郑州光合科技余经理5 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
feifeigo1235 天前
matlab画图工具
开发语言·matlab
dustcell.5 天前
haproxy七层代理
java·开发语言·前端
norlan_jame5 天前
C-PHY与D-PHY差异
c语言·开发语言
哇哈哈20215 天前
信号量和信号
linux·c++