蓝桥杯模版

全排列

public static void main(String[] args) {
		dfs(0);		
	}
	
	static int[] a = new int[] {1,2,3,4,5,7,8,9,10,12,13};
	static int n=11;
	static void dfs(int m) {
		if(m>=n) {
//			if....syso
			return;
		}
		
		for(int i=m;i<n;i++) {
			swap(i,m);
			dfs(m+1);
			swap(i,m);
		}
	}
	
	static void swap(int i,int j) {
		int t = a[i];
		a[i] = a[j];
		a[j] = t;
	}
 

质因数分解

public static Map<Integer,Integer> fj(int num){
		HashMap <Integer,Integer> m=new HashMap<>();
			for(int i=2;i*i<=num;i++) {
				while(num%i==0) {
					Integer t=m.get(i);
					if(t==null) {
						m.put(i, 1);
					}else {
						m.put(i,t+1);
					}
					num/=i;
				}
			}
	return m;
	}
		

容器

HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();

map.isEmpty() 			    //返回bool 查看map是否为空

map.containsKey(x) 			//返回bool 查看map中是否有x健
    
map.containsValue(x) 	    //返回bool 查看map中是否有x值

map.put(x, k);				// 给x初始值k  重复时为覆盖

map.putAll(mp);				// 把mp的键值对复制给map

map.get(x); 				// 获取x的对应的值

map.remove(x)               // 移除键为x的键值对
    
map.clear()                 // 清空map

for(int u : map.values() )  // 遍历map的元素集

for(int v : map.keySet() )  // 遍历map的键值对集 
 
for(Entry<Integer, Integer> entry : map.entrySet())   // 遍历map 

for(Map.Entry<Integer,Integer> x: list)
	x.getValue() / x.getKey()
    
map.put(s, (map.get(s) == null ? 1 : map.get(s) + 1));  //累加

一些单词

 false  true
 
 continue break 
 
 default(switch 语句)
 
 (set<int>) :: iterator it = s.begin();it<s.end();
 
 insert()// (set输入)

链表

public static void main(String[] args) {
    	Node n1=new Node(1);
    	Node p=n1;
    	for(int i=2;i<6;i++) {
    		p.next=new Node(i);
    		p=p.next;
    	}
    	p.next = n1;
        p = n1;
       
    	int t=0;
    		while(t<10) {
    			System.out.println(p.index);
    			p=p.next;
    			t++;
    		}
    	}
     

    
}
 class Node{
	 Node next;
	 int index;
	public Node(int index) {
		this.index=index;
	}

最大公约数

static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值