![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
Llaaq
这个作者很懒,什么都没留下…
展开
-
约瑟夫环,循环链表实现
约瑟夫环的定义就不再赘述,直接上代码。如果朋友能看完这个代码,相信你能理解接下里这个小故事。有个人想从这个世界上消失,但是他又不想死,他想到了一个办法,他可以把另外一个人杀了,然后再用这个人的身份生活下去。(这个小故事与约瑟夫环无关)#include <stdio.h>#include <malloc.h>struct node{ int data; struct node *next;};int main(){ int n, m;原创 2020-11-25 13:36:34 · 241 阅读 · 0 评论 -
PAT1031查验身份证
只有代码没有讲解,作为留念。#include<iostream>#include<string>using namespace std;int N;int quan[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; //权重const int maxn = 100; //可输入的最大值string s[maxn];原创 2020-07-01 16:35:12 · 114 阅读 · 0 评论 -
PAT乙级1018,锤子剪刀布(c++)
思路在代码中已经注释。#include<iostream>using namespace std;const int Maxn = 100101;int N;char dataMat[Maxn][2];int hCJB[2][3]; //用于存储甲乙胜利时所出的牌int hc1[2][3]; //用来存储甲乙的胜、平、分数量int getValue(char a, char b){ if(a == 'C' &&原创 2020-06-08 11:12:30 · 42451 阅读 · 0 评论 -
用数塔问题和斐波那契数列数列理解DP(小笔记)
一、斐波那契数列斐波那契数列:f(n) = f(n-1) + f(n-2),且f(0) = 1, f(1) = 1。由递归的思想我们可以知道:递归边界:f(1) = 0 || f(1) = 0;可得到代码:#include<cstdio>int F(int n){ if(n == 0 || n == 1){ return 1; } else{ return F(n-1) + F(n-2); }}int main(){原创 2020-06-02 16:33:31 · 255 阅读 · 0 评论 -
遍历数塔(C++)
#include<cstdio>#include<iostream>using namespace std;int shuta[200][200];int n;int max(int x, int y){ if(x > y){ return x; } else{ return y; }}int DFSshuta(int i, int j){ if(i == n){ retu原创 2020-06-02 15:00:36 · 43514 阅读 · 0 评论 -
PAT乙级1020月饼C++
题目:月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼。现给定所有种类月饼的库存量、总售价、以及市场的最大需求量,请你计算可以获得的最大收益是多少。注意:销售时允许取出一部分库存。样例给出的情形是这样的:假如我们有 3 种月饼,其库存量分别为 18、15、10 万吨,总售价分别为 75、72、45 亿元。如果市场的最大需求量只有 20 万吨,那么我们最大收益策略应该是卖出...原创 2020-03-18 18:30:13 · 43450 阅读 · 0 评论 -
PAT1023,组个最小数C++
题目:给定数字 0-9 各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意 0 不能做首位)。例如:给定两个 0,两个 1,三个 5,一个 8,我们得到的最小的数就是 10015558。现给定数字,请编写程序输出能够组成的最小的数。输入格式:输入在一行中给出 10 个非负整数,顺序表示我们拥有数字 0、数字 1、……数字 9 的个数。整数间用...原创 2020-03-19 09:10:01 · 109 阅读 · 1 评论 -
BFS计算走迷宫步数(c++)
#include<iostream>#include<cstring>#include<queue>#define maxn 100using namespace std;struct node{ int x,y; int step;}S ,T , Node;int n,m;char dataMat[maxn][maxn];...原创 2020-04-03 20:23:22 · 43429 阅读 · 0 评论 -
PATB1013(C++)
代码如下,需要的同学自取。#include<iostream>#include<math.h>#include<vector>using namespace std;bool ChargeData(int data){ if(data == 1){ return false; } int sqr = int(s...原创 2020-03-29 16:57:12 · 42494 阅读 · 0 评论 -
C/C++实现学生成绩管理系统
代码如下,需要的自取,有不对的请指出。#include<iostream>#include<stdio.h>#include<cstdlib>#define maxsize 3using namespace std;typedef struct sd{ int xuehao; char name[20]; int yuwen...原创 2020-03-28 22:51:13 · 49660 阅读 · 5 评论 -
C++实现分数的四则运算
代码如下,需要的自取,给个赞就好。#include<iostream>#include<stdlib.h>#include<cstdio>using namespace std;struct Fraction{ int up, down;};int gongYinshu(int data1, int data2){ //找到最大公约数 ...原创 2020-03-28 22:43:37 · 44654 阅读 · 1 评论