- 博客(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
106
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
114
原创 获取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
188
原创 查找学生信息 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
225
原创 复数集合
#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
334
原创 判断俩树是否相同
#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
174
原创 二叉排序树建树 中序遍历输出升序
#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
2016
原创 排序树建立并输出父节点
#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
113
原创 根据前序中序生成树
#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
344
原创 树的生成和遍历
#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
268
原创 打印字母金字塔
#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
347
原创 打印菱形
#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
66
原创 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
124
原创 全排列
#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
72
原创 杨辉三角形
#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
406
原创 汉诺塔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
114
原创 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
133
原创 大整数的因子
#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
103
原创 数字阶梯求和
#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
182
原创 递推数列
#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
83
原创 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
98
原创 矩阵乘积
#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
75
原创 约数的个数
#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
63
原创 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
59
原创 素数
#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
53
原创 最简真分数
#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
189
原创 最大公约数
#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
41
原创 数制转换
#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
51
原创 十六进制转十进制
#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
70
原创 又一版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
45
原创 进制转换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
90
原创 十进制与二进制
#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
65
原创 进制转换
#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
68
原创 二进制数
#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
95
原创 简单计算器
#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
78
原创 堆栈的使用
#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
93
原创 括号匹配问题
#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
44
原创 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
130
原创 猫狗收容所
#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
83
原创 约瑟夫问题
#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
46
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人