自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(44)
  • 收藏
  • 关注

原创 最大序列和

#include <iostream>#include <cstdio>using namespace std;int MaxSubsequence(int arr[],int n){ int dp[100]; int maximum; for(int i = 0;i < n; i++){ if(i == 0){ dp[i] = arr[i]; maximum = arr[i];

2021-03-03 16:06:05 77 1

原创 开门人和关门人 对象属性排序问题

#include <iostream>#include <cstdio>#include <vector>#include <string>#include <algorithm>using namespace std;struct Time{ string num; string begin; string end;};bool Compare(Time* a,Time* b){//这个星号没整明白

2021-02-27 14:49:21 79

原创 获取string所有子串 map迭代

#include <iostream>#include <cstdio>#include <map>using namespace std;int main(){ string str; while(cin>>str){ map<string,int> ma; for(int i = 1;i <= str.size();i++){ for(int j = 0;

2021-02-27 12:24:41 154

原创 查找学生信息 map使用

#include <iostream>#include <cstdio>#include <map>using namespace std;int main(){ int n; while(scanf("%d",&n) != EOF){ map<string,string> student; getchar();//吃掉回车 while(n--){ str

2021-02-27 11:54:16 189

原创 复数集合

#include <iostream>#include <cstdio>#include <string>#include <queue>using namespace std;struct Complex{ int real; int imag; Complex(int a,int b): real(a),imag(b){}//构造器 bool operator<(Complex c) const{//重写小于

2021-02-27 10:43:11 261

原创 判断俩树是否相同

#include <iostream>#include <cstdio>#include <string>using namespace std;struct TreeNode{ int data; TreeNode* leftchild; TreeNode* rightchild;};TreeNode* Build(TreeNode* root,int x){ if(root == NULL){ root =

2021-02-27 00:33:02 130

原创 二叉排序树建树 中序遍历输出升序

#include <iostream>#include <cstdio>#include <queue>using namespace std;struct TreeNode{ int data; TreeNode *leftchild; TreeNode *rightchild;};TreeNode* Insert(TreeNode* root, int x){//二叉排序树建树 if(root == NULL){

2021-02-26 22:19:43 1861

原创 排序树建立并输出父节点

#include <iostream>#include <cstdio>#include <queue>using namespace std;struct TreeNode{ int data; TreeNode *leftchild; TreeNode *rightchild;};TreeNode* Insert(TreeNode* root, int x, int father){ if(root == NULL){

2021-02-26 22:13:40 86

原创 根据前序中序生成树

#include <iostream>#include <cstdio>#include <queue>using namespace std;struct TreeNode{ int data; TreeNode *leftchild; TreeNode *rightchild;};TreeNode* Build(string str1,string str2){ if(str1.size() == 0) return NUL

2021-02-26 17:47:08 308

原创 树的生成和遍历

#include <iostream>#include <cstdio>#include <queue>using namespace std;struct TreeNode{ int data; TreeNode *leftchild; TreeNode *rightchild;};void InOrder(TreeNode* tree){//中序遍历 if(tree != NULL){ InOrder(tr

2021-02-26 17:23:25 233

原创 打印字母金字塔

#include <iostream>#include <cstdio>#include <string.h>using namespace std;int main(){ int n; while(scanf("%d",&n) != EOF){ int nj = 2*n -1; for(int i = 0;i < n;i ++){ int q = 0;

2021-02-25 22:34:59 262

原创 打印菱形

#include <iostream>#include <cstdio>#include <string.h>using namespace std;int main(){ int n; while(scanf("%d",&n) != EOF){ if(n % 2 == 0){ break; } for (int i = 0;i <n/2;i ++){

2021-02-25 21:48:53 41

原创 Fibonacci

#include <iostream>#include <cstdio>#include <string.h>using namespace std;int Fibonacci(int n){ if(n==1 || n==0){ return n; }else{ return Fibonacci(n-1)+Fibonacci(n-2); }}int main(){ //斐波那契 F(0)=0 F(

2021-02-24 23:59:45 95

原创 全排列

#include <iostream>#include <cstdio>#include <string.h>using namespace std;void permutation(char str[],int start,int end){//全排列递归 if(start == end){ cout << str << endl; }else{ for(int i = start;i &l

2021-02-24 22:46:44 44

原创 杨辉三角形

#include <iostream>#include <cstdio>using namespace std;int Factorial( int n){ if (n ==1 || n == 0 ){ return 1; }else{ return n * Factorial(n-1); }}int main(){ int n; while(scanf("%d",&n) != EOF){

2021-02-24 18:57:29 384

原创 汉诺塔3

#include <iostream>#include <cstdio>using namespace std;long long Func(int x){ if (x == 1){ return 2; }else { return 3* Func(x - 1) + 2; }}int main(){ int x; while(scanf("%d",&x) !=EOF){ prin

2021-02-24 17:42:02 85

原创 FatMouse‘ Trade

#include <iostream>#include <cstdio>#include <algorithm>using namespace std;struct Store{ double weight; double price;};bool Compare(Store a,Store b){ return a.price/a.weight < b.price/b.weight;}int main(){ doub

2021-02-23 22:53:14 87

原创 大整数的因子

#include <iostream>#include <cstdio>#include <stack>using namespace std;int main(){ string str; while(cin>>str){ int flag= 0; for(int i = 2;i <=9 ; i++){ int number = 0; for( in

2021-02-23 21:55:11 68

原创 数字阶梯求和

#include <iostream>#include <cstdio>#include <stack>using namespace std;int main(){ int a,n; while(scanf("%d%d", &a,&n) != EOF){ long long sum= 0;//int最多到2^31 2147483647 long long an = 0; for (

2021-02-23 16:32:26 150

原创 递推数列

#include <iostream>#include <cstdio>#include <stack>using namespace std;int main(){ int a0,a1,p,q,k; while(scanf("%d%d%d%d%d",&a0,&a1,&p,&q,&k) != EOF){ stack <int > sta; sta.push(a0);

2021-02-23 15:57:33 52

原创 A + B for Matrices

#include <iostream>#include <cstdio>#include <math.h>using namespace std;struct Matrix{ int matrix[10][10]; int row,col; Matrix(int r, int c): row(r),col(c){}};int main(){ int r,c; while(scanf("%d%d",&r,&

2021-02-23 15:37:49 68

原创 矩阵乘积

#include <iostream>#include <cstdio>#include <math.h>using namespace std;int main(){ int matrix1[2][3]; int matrix2[3][2]; for (int i = 0; i < 2; i++){ scanf("%d%d%d",&matrix1[i][0],&matrix1[i][1],&

2021-02-23 15:04:11 61

原创 约数的个数

#include <iostream>#include <cstdio>#include <math.h>#include <vector>using namespace std;int main(){ int n; while(scanf("%d", &n) != EOF){ int a; vector<int> vec; for(int i = 0;i <

2021-02-23 00:31:10 39

原创 Prime Number

#include <iostream>#include <cstdio>#include <math.h>using namespace std;bool IsSushu(int c){ for(int i = 2;i <= sqrt(c);i++){ if(c % i == 0){ return false; } } return true;}int main(){

2021-02-23 00:20:25 40

原创 素数

#include <iostream>#include <cstdio>#include <vector>using namespace std;bool IsSushu(int c){ for(int i = 2;i < c;i++){//这边可<=sqrt(c) math.h 复杂度O(sqrt(n)) if(c % i == 0){ return false; } }

2021-02-23 00:19:34 34

原创 最简真分数

#include <iostream>#include <cstdio>#include <vector>using namespace std;int GCD(int a, int b){ if( b == 0){ return a; }else { return GCD(b,a%b); }}int main(){ int n; while(scanf("%d",&n) != E

2021-02-22 18:29:52 149

原创 最大公约数

#include <iostream>#include <cstdio>using namespace std;int GCD(int a,int b){//欧几里得算法/辗转相除法 if(b == 0){ return a; }else { return GCD(b,a%b); }}int main(){ int a,b; while(scanf("%d%d",&a,&b) != EO

2021-02-22 17:52:10 26

原创 数制转换

#include <iostream>#include <cstdio>#include <stack>#include <math.h>using namespace std;int GetNumber(char c){ if(c >= '0' && c <= '9'){ return c - '0'; }else if(c >= 'a' && c <= 'z

2021-02-22 17:07:30 32

原创 十六进制转十进制

#include <iostream>#include <cstdio>#include <stack>#include <math.h>using namespace std;int GetNum(char c){ if(c >= '0' && c <= '9' ){ return c - '0'; }else if(c >= 'A' && c <= '9'){

2021-02-22 15:10:59 41

原创 又一版A+B

#include <iostream>#include <cstdio>#include <stack>using namespace std;int main(){ int m,a,b; while(scanf("%d",&m) != EOF){ if(m == 0){ break; } scanf("%d%d",&a,&b);//与while中的同一

2021-02-22 14:35:27 31

原创 进制转换2 有字母的待修改

#include <iostream>#include <cstdio>#include <math.h>#include <stack>using namespace std;int main(){ int M,N; while(scanf("%d%d",&M,&N) != EOF){ int X; scanf("%d",&X); int sum = 0;

2021-02-22 14:16:32 70

原创 十进制与二进制

#include <iostream>#include <cstdio>#include <math.h>#include <stack>using namespace std;int main(){ int A; while(scanf("%d",&A) != EOF){ stack<int> sta; while(A){//十进制->二进制 sta.

2021-02-22 11:27:36 47

原创 进制转换

#include <iostream>#include <cstdio>#include <math.h>#include <stack>using namespace std;int main(){ int n; while(scanf("%d",&n) != EOF){ int count = 0; stack<int> sta; int k = n;

2021-02-22 10:57:38 42

原创 二进制数

#include <iostream>#include <cstdio>#include <math.h>#include <stack>using namespace std;int main(){ unsigned int n; while (scanf("%d", &n) != EOF){ if (n<0 ||n > pow(10,8) ){ break;

2021-02-22 10:39:23 78

原创 简单计算器

#include <iostream>#include <string>#include <cstdio>#include <stack>using namespace std;double GetNum(string str,int& index){//用引用型 原参数的index会累加 double num = 0; while (isdigit(str[index])){ num = num * 10

2021-02-22 00:21:12 68

原创 堆栈的使用

#include <iostream>#include <string>#include <cstdio>#include <stack>#include <vector>using namespace std;int main(){ int n; while(scanf("%d",&n)!=EOF){ if (n == 0) break; char a; stac

2021-02-21 22:25:16 78

原创 括号匹配问题

#include <iostream>#include <string>#include <cstdio>#include <stack>using namespace std;int main(){ string str; while(cin >> str ){ if (str.size() <=0 || str.size() > 100){ break;

2021-02-21 14:52:15 32

原创 Zero-complexity Transposition

#include <iostream>#include <stack>#include <cstdio>using namespace std;int main(){ int n; while (scanf("%d",&n) != EOF && n > 0 && n <=10000){ stack<int> sta; int a; fo

2021-02-21 14:05:34 92

原创 猫狗收容所

#include <iostream>#include <cstdio>#include <queue>using namespace std;int main(){ int n; while (scanf("%d",&n)!=EOF){ int m,t; queue<int> que;//只存1 queue<int> que2;//只存2 for(in

2021-02-21 12:09:55 69

原创 约瑟夫问题

#include <iostream>#include <cstdio>#include <queue>using namespace std;int main(){ int n,p,m; while(scanf("%d%d%d",&n,&p,&m) != EOF) { if (n == 0 && p == 0 && m == 0){ break;

2021-02-21 11:19:28 32

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除