2019春招 微众银行笔试 java后台方向

尽管难度比较简单,但也需要准备充分呐。

题型分布:

选择题 20 * 2  + 编程题 20 * 3

选择题

1. java se 大概 十道题 

2. 编译原理(不多不难,就是做不出来)、计算机基础、(离散数学???)

编程题 第一题

/**
 * 这天,阳阳和他的小伙伴们一起玩游戏!
 * 他们总共有n个人,排成一圈,然后从第一个人开始依次报数,1,2,3,....,
 * 报到m的人退出游戏,然后从下一个人开始重新从1报数,重复这个过程,直到只剩下一个人时,此人就是游戏的获胜者
 */

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();

		scanner.close();
		solution(n, m);
	}

	private static void solution(int n, int m) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = i;
		}

		int count = 0;
		int totalCount = 0;
		boolean flag = true;
		int begin = 0;
		
		List<Integer> list = new LinkedList<>();
		
		while (flag) {
			for (int i = begin; i < array.length; i++) {
				
				if (count < m && array[i] != -1) {
					++count;
					if (count == m) {
						count = 0;
						++totalCount;
						array[i] = -1;
						list.add(i+1);
						continue;
					}
					continue;
				}
				
				if (count == 0 && array[i] != -1) {
					begin = i;
				}
				
				if (totalCount == n) {
					flag = false;
					break;
				}
			}
		}
		
		for (int i = 0; i < list.size() - 1; i++) {
			System.out.print(list.get(i) + " ");
		}
		System.out.println();
		System.out.print(list.get(list.size() - 1));
	}
}

编程题 第三题

使用递归,题目忘记了,有时间再补。。。


import java.util.Scanner;

//第三题
public class Main {
	public static void main(String[] args) {

		
		Scanner scanner = new Scanner(System.in);
		
		int T = scanner.nextInt();
		for (int i = 0; i < T; i++) {
			int m = solution(scanner.nextInt());
			System.out.println(m - 1);
		}
		
		scanner.close();
		
		
	}

	private static int solution(int n) {
		
//		System.out.println("n = " + n);
		
		int count = 0;
		
		if (n == 1) {
			count = 1;
			return count;
		}
		
		if (n > 1 && n % 2 == 0) {
			count++;
			count += solution(n / 2);
//			System.out.println("count : " + count);
		}
		
		if (n > 1 && n % 2 != 0) {
			count++;
			count += solution(n * 3 + 1);
//			System.out.println("count : " + count);
		}
		
		return count;
		
	}
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值