![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++,语法
文章平均质量分 52
Hormous的一天
这个作者很懒,什么都没留下…
展开
-
map与set的简单综合应用,统计单词词频
#include #include #include #include #include using namespace std; struct words{ string a; int numbers = 0; }; int main() { map mp; multimap mmp; char b[20];原创 2017-11-28 16:25:06 · 487 阅读 · 0 评论 -
填充函数
填充函数,主要有三种方法。我们看一下其算法的速度#include <bits/stdc++.h> #define INF 0x3f3f3f3f using namespace std; const int MAXN = (int)1e8; int a[MAXN]; int main() { int tim = clock(); memset(a,0x3f...原创 2018-03-04 09:12:06 · 1988 阅读 · 0 评论 -
string的加速及使用
令string加速输入的策略#include <bits/stdc++.h> using namespace std; string s; char a[100007]; string read(){ scanf("%s",a); string p = ""; for (int len = strlen(a),i = 0;i < len;i ++){ ...原创 2018-02-24 10:33:04 · 373 阅读 · 0 评论 -
关于全局变量与递归的进一步理解——加深迭代例题
原来这两个的关系一直没有弄得很清楚,经过一个bug的洗礼,我看透了很多题目链接:点击打开链接迷宫问题Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 28022 Accepted: 16150Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, ...原创 2018-02-12 22:41:25 · 1286 阅读 · 1 评论 -
关于C++的小贴士
#include 这个万能头文件,除了一些POJ,无法运行意外,别的地方基本都可以运行。 ios::sync_with_stdio(false); cin.tie(0); 代码中可以加上这一句话,来关闭cin,cout和printf,的同步系统,来实现输入输出的加速。 具体用法看样例 #include using namespace std; int main() {原创 2018-01-26 20:53:07 · 127 阅读 · 0 评论 -
c++语法补充+oj技巧讲解
for循环中定义的int I 只能在其作用域中。用cin 来输入 为什么是两个斜杠呢,因为在输入中无法输入单个斜杠,要用另外一个斜杠来转义它原创 2017-11-19 18:12:28 · 598 阅读 · 0 评论 -
有一个很帅的方法,可惜我对于string的原理还是不太懂 另外unique 和sort 可以处理string呢 嗯,解决了,但还可以优化哦
题目:点击打开链接#include #include #include #include #include using namespace std; string a[10000]; int main() { int i; char str[10000]; gets(str); char *p = strtok (str," "); while原创 2017-11-20 20:30:44 · 157 阅读 · 0 评论 -
指针和二维数组补充 和字符串
字符串最好不要加&符号。原创 2017-11-20 21:39:11 · 167 阅读 · 0 评论 -
C++中的文件录入,输出
#include <fstream> #include <iostream> using namespace std; void initial(){ ifstream infile; int n; char filename[50]; cout << "请输入目标文件名:" << e...原创 2018-01-24 21:32:02 · 472 阅读 · 0 评论 -
C++(清华篇)STL的基本概念
复杂函数,中要把迭代器当成中间值 好吧,接下来的课就没有听懂了,到时候再来吧 上天啊,后面就完全看不懂了原创 2017-11-29 14:52:18 · 217 阅读 · 0 评论 -
Class的初认识
不 如果使用的构造函数没有初始化呢,就会用类内的初始值原创 2017-11-29 15:59:00 · 162 阅读 · 0 评论 -
函数模板
typename 是类型参数,我们要用时,可以去指定这个类型参数 #include using namespace std; template T abs(T x){ return x < 0 ?-x:x; } int main(){ int n = -5; double d = -5.5; cout << abs(n) << endl; cout <原创 2017-11-29 16:30:16 · 178 阅读 · 0 评论 -
map容器的使用 加上一个map与set综合运用的例子
string的函数赋值可以直接赋值。 #include #include #include using namespace std; struct Student{ string name; int score; }; Student students[5] = { {"Jack",89},{"Tom",74},{"Cindy",87},{"Alysa",87},{原创 2017-11-29 16:31:15 · 585 阅读 · 0 评论 -
next_permutation函数初识
#include #define MAX_M 10 #define MAX_N 10 using namespace std; bool used[MAX_N]; int perm[MAX_M]; // 生成{1,2,3,4,....,n-1}的n!种排列 void permutation1(int pos,int n){ if (pos == n){ cout <原创 2017-12-09 10:53:36 · 260 阅读 · 0 评论 -
map函数的简单使用,和用pair判断的有无正确插入
#include #include #include using namespace std; struct Student{ string name; int score; }; Student students[5] = { {"Jack",89},{"Tom",74},{"Cindy",87},{"Alysa",87},{"Micheal",98} }; typedef原创 2017-11-27 16:28:55 · 472 阅读 · 0 评论 -
关于char[]类型的排序 和字符串在使用时可能char*更好用
typedef map<char*,int> MP;我骄傲啊,解决了世纪难题。原创 2017-11-26 19:52:24 · 1047 阅读 · 0 评论 -
multimap的简单使用 一道数据输入,查询的问题
cmd是用来接受命令的 然后需要把st中的元素插入mp中,虽然它们是可以对应起来的,但是毕竟类型是不同的 所以不能直接把st给插进去 那我们能够插入的是什么呢。 我们需要make a pair 就是make_pair这样的函数 mp.insert(make_pair(st.score,st.info)); 生成这个函数的时候,我们需要给他赋两个值 如果要查询的原创 2017-11-24 19:12:10 · 272 阅读 · 0 评论 -
segmentation fault - 了解
大神一号大神二号大神三号大神三号大神五号大神六号原创 2018-04-07 21:40:17 · 152 阅读 · 0 评论