- 博客(56)
- 资源 (1)
- 收藏
- 关注
原创 HJ3 明明的随机数
题目思路:定义一个长度为510的数组来表示输入的每个数字是否出现过。数组的值为1,表示已出现。数组的值为0,表示未出现。遍历数组,依次判断即可。
2023-08-17 21:11:01
200
原创 简述 C++ vector 的用法
动态数组:主要有 vector的初始化、插入、访问、大小和容量和deque的插入和删除#include<vector>using namespace std;int main(){ // 一 初始化 // 初始指定长度 为10 vector<int> a (10); // 初始为 10 个 5 vector<int> b ( 10, 5); // 复制 vector<int> c (b); // 指定范围的 复制
2021-04-08 22:53:36
104
原创 简述C++ string的用法
7个部分初始化、访问、拼接、查找、截短、反转、大小写转换#include<string>#include<iostream>using namespace std;int main(){ const char* a = "Hello World!";// 常量字符串 cout << a << endl; // 一 //sting的初始化 //复制 string b (a); // string b = a; cout &l
2021-04-08 09:40:20
144
原创 C/C++ 学生信息管理系统
#include<iostream>#include<string.h> #include<stdlib.h>using namespace std;// 学生信息结构体 STU 的定义 typedef struct { char name[10]; // 姓名 char num[20]; // 学号 char class_[10]; // 班级 double score[3]; // 3门学科成绩(离散数学、英语、微积分) }STU;c
2020-11-12 15:41:40
147
原创 顺序栈的基本操作
//constant.h#define OK 1#define ERROR 0#define OVERFLOW -2#define TURE 1#define FALSE 0 typedef int Status;//SqStack.h#define STACK_INIT_SIZE 10#define STACK_INCREMENT 5struct SqStack{ SElemType *base; SElemType *top; int stacksize;};//顺序栈
2020-10-15 20:28:50
172
原创 单链表的基本操作
//LinkList.htypedef int ElemType;typedef struct LNode{ ElemType data; struct LNode *next;}LNode, *LinkList;//LinkList_Operation.cppusing namespace std;// 1 单链表的初始化 Status InitList(LinkList &L){ L = new LNode; L->next == NULL; return OK;
2020-10-14 20:41:59
101
原创 线性表操作
//SqList.h#define MAXSIZE 100typedef int ElemType;typedef struct{ ElemType *elem;//存储空间的基地址 int length;//当前长度 }SqList;//顺序表SqList //SqList_Operation.cpp// 1 InitList 构建空表Status InitList(SqList &L){ L.elem = new ElemType[MAXSIZE];//为线性表动态分配一个
2020-10-12 20:27:12
92
原创 C++ priority_queue 基本操作
#include<queue>using namespace std;int main(){ priority_queue <int> a; priority_queue <double> b; priority_queue < int, vector <int>, greater <int> > c; priority_queue <int> d( a);} #include<queue>
2020-09-28 08:16:11
110
原创 C++ queue 基本操作
#include<queue>#include<list>using namespace std;int main(){ queue <int> a; queue <double> b; queue <double, list <double> > c;//use list queue <int> d( a);} #include<queue>#include<iostream>
2020-09-28 08:15:23
211
原创 C++ stack 基本操作
#include<stack>#include<vector>using namespace std;int main(){ stack <int> a; stack <double> b; stack <int, vector <int> > c; // 选用vector stack <int> d( a);}#include<stack>#include<iostream>
2020-09-28 08:13:41
292
原创 C++ lower_bound upper_bound
#include<vector>#include<iostream>#include<algorithm>using namespace std;void show( const vector <string> a){ for(auto p = a.begin(); p != a.end(); p ++) cout << *p << endl; cout << endl;}int main(){ ve
2020-09-26 12:19:21
148
原创 C++ partition stable_partition
#include<vector>#include<algorithm>#include<iostream>using namespace std;void show( const vector <int> a){ for(auto p = a.begin(); p != a.end(); p ++) cout << *p << ' '; cout << endl;}int main(){ vecto
2020-09-26 12:18:17
140
原创 C++ binary_search unique
#include<vector>#include<string>#include<iostream>#include<algorithm>using namespace std;void show( const vector <string> a){ for(auto p = a.begin(); p != a.end(); p ++) cout << *p << endl; cout <<
2020-09-26 12:17:19
144
原创 C++ replace replace_if
#include<vector>#include<iostream>#include<algorithm>using namespace std;void show( vector <int> &a){ for(auto p = a.begin(); p != a.end(); p ++) cout << *p << ' '; cout << endl;}int main(){ vector
2020-09-26 12:16:12
172
原创 C++ copy_backward
#include<vector>#include<iostream>#include<algorithm>using namespace std;int main(){ vector <int> a{ 1, 2, 3, 4, 5}, b(5); //copy_backward( iterator first, iterator last, iterator) 沿反方向复制 返回一个指向复制结束位置的的迭代器 auto i = copy_b
2020-09-26 09:54:13
189
原创 C++ copy copy_if remove remove_if
#include<vector>#include<list>#include<iostream>#include<algorithm>using namespace std;void show( const vector<int> &a){ for(auto p = a.begin(); p != a.end(); p ++) cout << *p << ' '; cout << en
2020-09-26 09:53:34
132
原创 C++ transform
#include<string>#include<vector>#include<deque>#include<algorithm>#include<iostream>#include<functional>using namespace std;template <typename T>void show(const T& a){ for(auto p = a.begin(); p != a.e
2020-09-26 09:52:15
143
原创 C++ for_each
#include<vector>#include<string>#include<iostream>#include<algorithm>using namespace std;struct show{ int count; show (): count(0){} void operator()(const char& c){ cout << c; count ++; }};int main(){ vec
2020-09-26 09:51:11
89
原创 C++ generate generate_n
#include<vector>#include<list>#include<iostream>#include<algorithm>using namespace std;template <typename T>void show( const T& a){ for(auto p = a.begin(); p != a.end(); p ++) cout << *p << ' '; cout
2020-09-26 09:50:07
368
原创 C++ fill fill_n
#include<algorithm>#include<vector>#include<iostream>using namespace std;int main(){ vector <int> a(10); //fill( iterator first, iterator last, key) fill( a.begin(), a.end(), 1); a.resize(15); //fill_n( iterator first, n
2020-09-25 17:22:34
104
原创 C++ search search_n
#include<vector>#include<iostream>#include<list>#include<algorithm>using namespace std;int main(){ vector <int> a; for(int i = 0; i < 10; i ++) a.push_back( i); a.push_back( 9); a.push_back( 9); for(auto i =
2020-09-25 17:21:58
340
原创 C++ count count_if
#include<vector>#include<iostream>#include<algorithm>using namespace std;int main(){ vector <int> a; a.push_back( 1); a.push_back( 1); a.push_back( 2); a.push_back( 2); a.push_back( 3); a.push_back( 3); int count1, co
2020-09-25 17:21:20
137
原创 C++ find find_if
#include<vector>#include<algorithm>#include<iostream>using namespace std;int main(){ vector <int> a{ 1, 2, 3, 4, 5}; int x; cout << "put in the value you want to search" << endl << '>'; cin >> x
2020-09-25 17:20:42
273
原创 C++ lambda表达式的通用格式
#include<bits/stdc++.h>using namespace std;int main(){ //在此总结一下lambda表达式的通用格式 //[ State(&引用__无&时 状态变量为只读模式,不可在表达式内修改) 1, State(&) 2, ...] //( elemtype(&引用) 1, elemtype(&) 2, ...] //(mutable)__用于在表达式内修改状态变量且修改只在表达式内有效 __当状态变
2020-09-25 12:22:18
395
原创 C++ 二元谓词对应的lambda表达式
#include<vector>#include<string>#include<algorithm>#include<iostream>using namespace std;template <typename T>void show( const T& a){ for(auto p = a.begin(); p != a.end(); p ++) cout << *p << endl;
2020-09-25 12:21:21
282
原创 C++ 二元函数对应的lambda表达式
#include<algorithm>#include<vector>#include<iostream>using namespace std;int main(){ vector <int> a{ 1, 2, 3, 4, 5}, b( a), c( a.size()); //二元函数对应的lambda表达式 transform( a.begin(), a.end(), b.begin(), c.begin(),[](int a, int
2020-09-25 12:20:28
386
原创 C++ 接受状态变量的lambda表达式
#include<algorithm>#include<vector>#include<iostream>using namespace std;int main(){ vector <int> a{ 1, 3, 5, 7, 9, 11}; int x; cout << "input 除数 x" << endl << '>'; cin >> x; //通过捕获列表[...]接受状
2020-09-25 12:19:50
369
原创 C++ 一元谓词对应的lambda表达式
#include<vector>#include<algorithm>#include<iostream>using namespace std;int main(){ vector <int> a{ 1, 3, 5, 7, 9, 11}; //一元谓词对应的lambda表达式 -- a > 7 是 return ture auto p = find_if( a.begin(), a.end(), [](int& a){
2020-09-25 12:17:11
336
原创 C++ 一元函数对应的 lambda表达式
#include<algorithm>#include<vector>#include<list>#include<iostream>using namespace std;int main(){ vector <int> a{ 1, 2, 3, 4, 5}; // 一元函数对应的 lambda表达式 for_each( a.begin(), a.end(), [](int& a){ cout <<
2020-09-25 12:16:08
228
原创 C++ 一元函数 一元谓词 二元函数 二元谓词
21C++ 的 21章#include<algorithm>#include<vector>#include<list>#include<iostream>using namespace std;template <typename T>struct show{ void operator() (const T& a) const{ cout << a << ' '; }};int mai
2020-09-24 20:55:45
428
原创 STL map multimap 一些基本操作
21C++ STL map 一些基本操作#include<map>#include<string>using namespace std;int main(){ map <int, string> a1; multimap <int, string> a2; map <int, string> b1( a1); multimap <int, string> b2( a2); map <int, stri
2020-09-23 17:09:27
114
原创 21C++ STL set multiset 一些基本操作
一些基本操作#include<set>using namespace std;int main(){ set <int> a{ 1, 2, 3, 4}; multiset <int> b; set <int> c( a); multiset <int> d( a.begin(), a.end());//两个描述边界的迭代器 }#include<set>#include<iostream>us
2020-09-22 19:38:19
134
原创 21C++ STL list 基本操作
一些基本操作#include<list>#include<vector>using namespace std;int main(){ list <int> a;//空链表 list <int> b(10);//10个元素 list <int> c( 10, 90);// 10 个 90 vector <int> d( 5, 9); list <int> e( d.cbegin()
2020-09-21 22:25:59
88
原创 21C++ STL forward_list 单向链表
一些基本操作#include<iostream>using namespace std;template <typename T>void show(const T& a){ for(auto i = a.begin(); i != a.end(); i ++) cout << *i << ' '; cout << endl;}int main(){ forward_list <int> a; //单向
2020-09-21 22:25:38
135
原创 反片语 UVA 156
输入一些单词,找出所有满足如下条件的单词:该单词不能通过字母重排,得到输入文本中的另外一个单词。 在判断是否满足条件时,字母不分大小写,但在输出时应保留输入中的大小写,按字典序进行排列(所有大写字母在所有小写字母的前面)。Sample Inputladder came tape soon leader acme RIDE lone Dreis peatScAlE orb eye Rides dealer NotE derail LaCeS drIednoel dire Disk mace Rob d
2020-09-21 08:42:05
214
原创 21C++ STL vector 练习题
17章作业#include<vector>#include<algorithm>#include<iostream>using namespace std;int fun(){ cout << "please select" << endl; cout << "1 to add data" << endl; cout << "2 to find data" << endl; co
2020-09-21 08:16:12
1002
真值表、主析取范式、主合取范式
2020-10-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人