- 博客(19)
- 收藏
- 关注
原创 2021-11-10
从两个袋子里摸球详情请见[蓝桥杯2016决赛]随意组合 static void bfs(array a[], array b[], int c, List<int[]>lists, List<Integer>list, Map<String,Integer>hashmap){ if (c==4) { int t[]=new int[4]; for (int ti=0;ti<4;ti+
2021-11-10 15:23:43 58
原创 2021-11-01
全排列不重复static void bfs(List<Integer> a, List<List<Integer>> lists, List<Integer> list, int i) { if (i == 8) { lists.add(new ArrayList<>(list)); } else { for (int j = 0; j < a.size();
2021-11-01 14:23:16 52
原创 2021-10-19
刷题心得2public class lanjiao { public static void main(String args[]){ char word[]=new char[19];//装着abcdefghijklmnopqrs for(int i=97;i<=97+18;i++) { word[i-97]=(char) i; } char w[]=new char[2*19];//然后装106
2021-10-19 21:38:16 42
原创 2021-10-19
刷题心得读取空白字符(蓝桥杯常用)public class lanjiao { public static void main(String args[]){ String s; List<Integer>list=new ArrayList<>(); Scanner in=new Scanner(System.in); int n=in.nextInt(); for (int i=0;i&l
2021-10-19 21:07:42 45
原创 2021-06-07
回溯=dfs+剪枝力扣全排列class Solution { public List<List<Integer>> permute(int[] nums) { List<List<Integer>> res = new ArrayList<List<Integer>>(); List<Integer> output = new ArrayList<Integer>()
2021-06-07 15:17:52 41
原创 2021-06-07
`class Solution {public List<List> permute(int[] nums) {List<List> res = new ArrayList<List>(); List<Integer> output = new ArrayList<Integer>(); for (int num : nums) { output.add(num); } int n = nums
2021-06-07 15:10:20 39
原创 2021-05-08
求一个自然数的所有因子#include<iostream>#define ll long longusing namespace std;int main(){ long long b[10000]; long long a; int k=0; int count=0; cin >> a; for(long long i=1;i*i<=a;i++) { if(a%i==0)
2021-05-08 17:37:07 48
原创 2021-05-08
#include<iostream>#define ll long longusing namespace std;int main(){ long long b[10000]; long long a; int k=0; int count=0; cin >> a; for(long long i=1;i*i<=a;i++) { if(a%i==0) { b[k++]=i;
2021-05-08 17:34:33 47
原创 2020-12-13
创建链表简洁易懂版``` public ListNode create(int n) { ListNode head = null; ListNode p = null; ListNode r=null; for(int i=0;i<n;i++) { p=new ListNode(); p.next=null; p.val=1;
2020-12-13 09:47:59 50
原创 2020-11-19
多个数的最小公倍数#include<iostream>using namespace std;int main(){ int a,b,c; cin >> a>>b>>c; int t=a*b*c; for(int i=1;i<=t;i++){ if(i%a==0&&i%b==0&&i%c==0) { cout << i&l
2020-11-19 13:21:53 62
原创 2020-11-18
希尔排序//希尔排序#include<iostream>using namespace std;void shellsort(int* a, int n){ int t; for (int k = 0; k <sizeof(a); k++) { if(k+n<sizeof(a)) { for(int i = k; i < sizeof(a); i = i + n) { for
2020-11-18 19:10:52 43
原创 2020-11-18
快速排序void qsort(int* a,int n){ if(n>1) { int i=-1; int j=0; int k=n-1; int t; for(j=0;j<n-1;j++) { if(a[j]<a[k]) { i++; t=a[j];a[j]=a[i];a[i]=t; } } t=a[i+
2020-11-18 19:07:17 46
原创 2020-10-30
链表的删除static student del(student p,int n) { student t=p; student r=null; while(t!=null){ if(t.num==n) { if(t==p) p=p.next; else r.next=t.next;
2020-10-30 20:23:02 69
原创 2020-10-30
辗转相除法求最大公约数int Euclidean(int a,int b){ int min=a<b?a:b; int max=a>b?a:b; int n=-1; while(n!=0) { n=max%min; max=min; min=n; } return max;}
2020-10-30 18:35:21 57
原创 2020-10-28
高精加int* add(int *a,int *b,int a_size,int b_size,int &k){ int *c=new int[N]; int i=N/2+a_size,j=N/2+b_size;int n,d=0; int ma=max(a_size,b_size); for(k=0;k<ma;k++) { n=(a[--i]+b[--j]+d); c[k]=n%10; d=n/
2020-10-28 19:03:15 47
原创 2020-10-28
c++局部变量的回收机制局部变量存放在栈中时离开作用域则被系统自动回收,若在堆中则不受作用域管理,不会被系统自动回收,例如new出来的空间只有在使用delete删除或者整个程序结束后才会释放掉。#includeusing namespace std;int text(){intp=new int[3];p[1]=2;cout << p[1] << endl;return p;}int main(){int*p=text();cout << p[
2020-10-28 18:46:34 50
原创 2020-10-27
存储大数值int bignum(int a[]){char n;int i=0;n=cin.get();while(n!=’\n’){a[i++]=(int)n-48;n=cin.get();}return i;}
2020-10-27 18:57:59 60
原创 2020-04-14
#includeusing namespace std;class bb;//只声明类而不定义它class yy{private: int r; int e;public: yy() { r = 1; } friend bool operator >(yy a,bb b);};class bb{private: int e;public: bb() { e = 2; } friend ...
2020-04-14 15:48:32 86
原创 2020-03-24
标题 哪种情况下派生类对象不能访问基类的公有成员给定三个类a,b,c他们的关系是:a派生b派生c,也就是a是爷爷,b是爸爸,c是儿子,在主函数中定义一个c类对象,而这个对象不能访问a类的公有成员如函数,为什么会出现这种情况?...
2020-03-24 17:03:33 66
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人