2021年5月10日

dev编译器兼容设置及字符串的识别问题

摘要: #include<bits/stdc++.h> using namespace std; bool cmp(char a,char b) { return a>b; } //int stoint(string s){ // int sum=0; // for( int i=0;i<s.length( 阅读全文

posted @ 2021-05-10 22:58 ewitt 阅读(143) 评论(0) 推荐(0) 编辑

2021年4月29日

产生01全排列字符串

摘要: #include <iostream> using namespace std; int a[10][10]; static int r=0; void f(int k) { if(k==4){ cout<<a[r][1]<<a[r][2]<<a[r][3]<<endl; r++;} else{ a 阅读全文

posted @ 2021-04-29 14:59 ewitt 阅读(95) 评论(0) 推荐(0) 编辑

2021年4月7日

学生练习:中缀表达式求值

摘要: #include<iostream> #define MAXSIZE 20 #define OK 1 #define ERROR 0 using namespace std; typedef struct stack { char *elem; int top; } Sqstack; void in 阅读全文

posted @ 2021-04-07 08:38 ewitt 阅读(26) 评论(0) 推荐(0) 编辑

学生练习:括号匹配

摘要: #include <iostream> using namespace std; #define STACKSIZE 10 typedef struct { int *base; int top; int StackSize; } SqList; void initStack(SqList *&s) 阅读全文

posted @ 2021-04-07 08:37 ewitt 阅读(42) 评论(0) 推荐(0) 编辑

2021年4月6日

迷宫问题,打印所有路径,深度搜索,dfs

摘要: 迷宫问题,打印所有路径,深度搜索,dfs 阅读全文

posted @ 2021-04-06 18:21 ewitt 阅读(127) 评论(0) 推荐(0) 编辑

vector用法

摘要: #include<bits/stdc++.h>using namespace std;int maze [5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};typedef struct { 阅读全文

posted @ 2021-04-06 17:28 ewitt 阅读(55) 评论(0) 推荐(0) 编辑

2019年11月22日

数据结构中的树相关编程题

摘要: 数据结构中的树相关编程题 2017(3): 计算并输出树中每个叶子结点的data域值与所在的层数(递归) void fun(TNode *t,int h) //t为树结点指针,h为该结点深度 { if(t == NULL) return; //如果该结点为空,直接退出该函数 if(t->firstc 阅读全文

posted @ 2019-11-22 10:39 ewitt 阅读(657) 评论(0) 推荐(0) 编辑

2019年11月20日

dp:最长非递减序列

摘要: This state carries only data about the length of this sequence. Note that for i<j the state i is independent from j, i.e. doesn’t change when we calcu 阅读全文

posted @ 2019-11-20 15:50 ewitt 阅读(118) 评论(0) 推荐(0) 编辑

dp:找零问题

摘要: C代表币的种类,n代表钱数 #include<iostream> using namespace std; #define C 4 void main( ) { int coin[4]={1,3,5,10}; int i,j,n=20,dp[20]={0}; for(i=1;i<20;i++) dp[i]=100; for(i=1;i<=n;i++) { for(j=0;j<C;j++) if(i 阅读全文

posted @ 2019-11-20 15:20 ewitt 阅读(196) 评论(0) 推荐(0) 编辑

2019年9月29日

递归求数组最小值; 递归求数组的平均值

摘要: 递归求数组的平均值 #include <iostream.h> int a[10]={6,2,7,3}; float avg(int n)//n代表元素个数 { if(n==1) return a[0]; return (a[n-1]+avg(n-1)*(n-1))/n; } //一个递归调用(此处为avg(n-1))就相当于一个循环 void main() { int n; cin>>n; co 阅读全文

posted @ 2019-09-29 21:58 ewitt 阅读(1310) 评论(0) 推荐(0) 编辑

导航