摘要: vector非结构体,const不要忘了 #include<iostream> #include<algorithm> #include<vector> using namespace std; bool cmp(const int &x,const int &y){ return x>y; } i 阅读全文
posted @ 2019-02-09 15:23 Hello_World2020 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 最长公共子序列 //最长公共子序列(个数) #include<iostream> using namespace std; int c[100][100]={0}; int len1,len2; int gcd(string a,string b){ len1=a.length(); len2=b. 阅读全文
posted @ 2019-02-09 11:31 Hello_World2020 阅读(648) 评论(1) 推荐(0) 编辑
摘要: 1.自底向上与自顶向下 //自底向上 #include<iostream> using namespace std; int f[101]; int main() { int n; f[1]=1; f[2]=1; while(cin>>n){ for(int i=3;i<=n;i++){ f[i]= 阅读全文
posted @ 2019-02-07 09:49 Hello_World2020 阅读(497) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; int migo[7][7]={ {2, 2, 2, 2, 2, 2, 2}, {2, 0, 0, 0, 0, 0, 2}, {2, 0, 2, 0, 2, 0, 2}, {2, 0, 0, 0, 0, 2, 2}, { 阅读全文
posted @ 2019-02-06 19:21 Hello_World2020 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 1.括号的匹配 #include<iostream> #include<stack> using namespace std; int check(string str){ stack<char> s; int len=str.length(); for(int i=0;i<len;i++){ ch 阅读全文
posted @ 2019-02-06 15:20 Hello_World2020 阅读(227) 评论(0) 推荐(1) 编辑
摘要: 计数排序 假设一个数组arr[0...n] 找到最大的值max 然后新建一个数组book[0...max]={1} 遍历数组arr,arr[i]=j book[j]++ 最后遍历数组book[0...max] b[i]=b[i-1]+b[i] #include<iostream> #include< 阅读全文
posted @ 2019-02-05 22:37 Hello_World2020 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 类的描述分为两个部分,public和private public可以用来定义函数,对类的对象进行操作,对于用户是可见的,是用户对对象操作的唯一手段。 private部分用于定义函数和数据成员,这些函数和数据成员对于用户是看不见的 借助于public与private部分,可以让用户只看到他们需要看到的 阅读全文
posted @ 2019-02-05 16:54 Hello_World2020 阅读(804) 评论(0) 推荐(0) 编辑
摘要: 1.选择排序 每一次找出最小的值,放在最前面的位置,一个一个安置 //选择排序 #include<iostream> #include<climits> using namespace std; template<class T> void gcd(T a[],int n){ int mix,tem 阅读全文
posted @ 2019-02-03 22:19 Hello_World2020 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 构造一个新数组,将对应位置的数字,从大到小或从小到大排序的名次存储,并输出 //计算名次 #include<iostream> #include<cstring> using namespace std; int book[101]; void rank(int *a,int n,int book[ 阅读全文
posted @ 2019-02-03 22:13 Hello_World2020 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; template<class T> T ploy(T *coeff,int n,const T&x){ T value=coeff[n]; for(int i=1;i<=n;i++) value=value*x+coef 阅读全文
posted @ 2019-02-03 22:10 Hello_World2020 阅读(269) 评论(0) 推荐(0) 编辑