vector
今天吃白斩鸡了吗
这个作者很懒,什么都没留下…
展开
-
质因数分解
#include <stdio.h>#include <vector> using namespace std;struct NodeType { int p; int pc; //vector 向 量 元 素 类 型 // 质 因 数 出 现 次 数};void solve(int n, vector<NodeType>& v){int ic = 0;int i = 2;NodeType e;do{ if (n % i =原创 2022-03-03 19:33:57 · 101 阅读 · 0 评论 -
找到(find)并删除(eraser)
删除公共字符Description输入两个字符串,从第一个字符串中删除第二个字符串中的所有字符,例如输入"They are students"和"aeiou",则删除之后的第一个字符串变成"Thy rstdnts"。Input输入包含两行,分别为两个字符串。第二个字符串中不会含有空格。Output输出一行,为删除后的字符串。Sample Input 1They are studentsaeiouSample Output 1Thy r stdnts#include <iostr原创 2022-03-03 17:38:38 · 316 阅读 · 0 评论 -
vector<int> v,vector<int> v(n),vector<int> v[n]的区别
对于vector<int>arr,是指没有确定容量,这时候需要使用push_back函数进行输入运行: vector<int> v; cout << v.size();输出为:0对于vector<int>arr(n),相当于vector<int>arr(n,0),也就是vector<int>arr(n,val),对一个确定容量n的动态数组arr的所有元素赋值0,也就是val运行: vector<int>原创 2021-09-12 21:14:11 · 1075 阅读 · 0 评论 -
vector如何输入结构体的某一项
struct loca { int loc; int dir;};int main(){ int n, L, t; cin >> n >> L >> t; vector<loca>arr(n); for (int i = 0, i < n; i++) { loca pos;//当作临时变量 cin >> pos.loc; arr.push_back(pos); } return 0;}...原创 2021-09-12 19:57:20 · 623 阅读 · 0 评论