
c++
文章平均质量分 74
有趣的人
有趣的大学生啊
展开
-
c++ 第三阶段
前缀表达式#include<iostream>using namespace std;double operation(){ char s[10]; cin >> s; switch (s[0]) { case '+':return operation() + operation(); case '-':return operation() - ope...原创 2019-12-03 21:52:24 · 320 阅读 · 0 评论 -
c++ 递归训练
#include <iostream>using namespace std;int f(int n){ if (n <=2)//递归结束条件 return n; else return f(n - 1) + f(n - 2);}int main(){ int n; cin >> n; cout << f(n);}#...原创 2019-11-19 22:02:19 · 922 阅读 · 0 评论 -
c#推箱子修改
推箱子修改以下代码仅为部分代码举例,具体请见项目。1. 在静态类constant中定义所有数字常量,数字常量名全部为大写字母。static class constant { //空地/墙/箱子 public const int BLANK = 0,WALL = 1,BOX = 3, DESTINATION = 0, PEOPLE = 6; ...原创 2019-11-15 21:49:08 · 494 阅读 · 0 评论 -
c++ P大计算概论2019期中
第一题注意0和输出最后没有逗号,注意若没有要输出NO#include<iostream>#include<algorithm>using namespace std;int main(){ int n; cin >> n; int a[202]; int b[40000], c[40000]; int count = 0; for (in...原创 2019-11-09 22:51:56 · 225 阅读 · 0 评论 -
c++ 辗转相除类题目
辗转相除法:设两数为a、b(a>b),求a和b最大公约数(a,b)的步骤如下:用b除a,得a=bq…r1(0≤r1)。若r1=0,则(a,b)=b;若r1≠0,则再用r1除b,得b=r1q…r2 (0≤r2).若r2=0,则(a,b)=r1,若r2≠0,则继续用r2除r1,……如此下去,直到能整除为止。其最后一个非零除数即为(a,b)1.求最小公倍数思路:先用辗转相除法求出最大公约数,然...原创 2019-11-08 21:00:52 · 1062 阅读 · 0 评论 -
c++ HashMap
HashMapmap用法总结hashmap简单介绍#include< map>数据结构基于哈希表,以空间换时间,是存储key-value键值对的集合。基本原理:使用一个下标范围比较大的数组来存储元素。可以设计一个函数(哈希函数,也叫做散列函数),使得每个元素的关键字都与一个函数值(即数组下标,hash值)相对应,于是用这个数组单元来存储这个元素;也可以简单的理解为,按照关键...原创 2019-11-08 20:04:22 · 5173 阅读 · 2 评论 -
c++ 期中阶段练习
大概思路:先求出第 i 行第 j 列的格左相邻的 0 的个数(包含自身)然后把它当做矩形右下角来往上求最大的宽,求最大面积#include <iostream>using namespace std;int min(int a, int b){ return a < b ? a : b;};int max(int a, int b){ return a &g...原创 2019-11-03 11:08:29 · 243 阅读 · 0 评论 -
c++ 贪心算法
活动选择问题#include <iostream>using namespace std;struct Act{ int start; int end; bool flag;} activity[99999];int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin &g...原创 2019-11-03 11:08:14 · 2786 阅读 · 1 评论 -
C++ 考试易错点
结构体数组的数据交换,则所有数据都交换 例如 交换a.data和b.data,则相应的a.index和b.index也会自动就交换注意数组应该开多大 题目没有明确表示就开大点吧使用循环嵌套时,注意变量不要重复!不要打错 i j k注意输出方式,输入如果有逗号要考虑char ch,有空格需要考虑cin.get(ch)...原创 2019-10-22 20:04:53 · 252 阅读 · 0 评论 -
C++ 蛇形矩阵类题目
大致分为三类:拐角方阵,螺旋矩阵,蛇形矩阵(2种 )拐角矩阵输入:7输出样例:1 1 1 1 1 1 11 2 2 2 2 2 21 2 3 3 3 3 31 2 3 4 4 4 41 2 3 4 5 5 51 2 3 4 5 6 61 2 3 4 5 6 7#include<iostream>;using namespace std;int main()...原创 2019-10-19 22:02:01 · 3174 阅读 · 0 评论 -
C++ 指针类型
原创 2019-10-16 13:46:23 · 153 阅读 · 0 评论 -
C++ 计算概论A作业(第一阶段练习)
牛顿迭代求根#include<iostream>#include<cmath>#include<iomanip>using namespace std;/*x(n+1)=x(n)-f(x(n))/f'(x(n))称为r的n+1次近似值上式称为牛顿迭代公式*/double newtoon(double n){ int i = 1; if...原创 2019-10-15 17:13:16 · 352 阅读 · 0 评论 -
C++ 计算概论A作业(第二周)
1.房价VS年薪#include<iostream>using namespace std;int purchase(double x,double m){ int year=1; double sum=x; double temp; while(sum<m) { year++; x*=1.08; sum=sum+x; m*=1.1; } re...原创 2019-09-27 19:41:13 · 797 阅读 · 0 评论 -
C++ 计算概论A作业(第一周)
1. 两数之和#include<iostream>using namespace std;int main(){ int a,b; cin>>a>>b; a+=b; cout<<"The sum is "<<a<<endl;}2.习题(4-5) 最大数输出#include<iostream&g...原创 2019-09-26 19:09:38 · 234 阅读 · 0 评论 -
链表的几个基础问题
*链表的管理 *出圈问题 *约瑟夫环问题(变种) *用插入法建立有序链表 *链表中节点的查找与定位链表的管理#include<iostream> using namespace std; struct node { int data; node *next; };//node node *head=NULL; void showList(){...原创 2018-03-28 17:21:18 · 238 阅读 · 0 评论