今晚微众银行的笔试有没有大佬解答一下编程题

如题#微众银行##笔试题目#
全部评论
public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); int[] res = support(n); System.out.println(res[0] + "/" + res[1]); } } public static int[] support(int n){ int[] res = new int[2]; int count = 1; int rowIndex = 1; int colIndex = 1; boolean flag = true; //标识,表示转方向 if(n == 1){ res[0] = rowIndex; res[1] = colIndex; return res; } while(count != n) { if (rowIndex == 1 && flag) { colIndex++; count++; flag = false; } while (colIndex != 1 && count != n) { colIndex--; rowIndex++; count++; } if (colIndex == 1 && !flag) { rowIndex++; count++; flag = true; } while (rowIndex != 1 && count != n) { rowIndex--; colIndex++; count++; } } res[0] = rowIndex; res[1] = colIndex; return res; } }
点赞 回复 分享
发布于 2019-03-24 21:09
你是什么岗的笔试呀兄弟
点赞 回复 分享
发布于 2019-03-24 21:10
有点难啊
点赞 回复 分享
发布于 2019-03-24 21:10
第一道题找规律,第二道题贪心,第三道题没时间看qaq
点赞 回复 分享
发布于 2019-03-24 21:16
有没有人跟我一样算法只对了一个
点赞 回复 分享
发布于 2019-03-24 21:58
第一题不难 先算一个等差 再判断下奇偶 做个加法减法就出来了
点赞 回复 分享
发布于 2019-03-24 23:15
你有消息了吗,我考完到现在还没任何消息
点赞 回复 分享
发布于 2019-03-28 16:14
public class Game { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = 0, m = 0; while (scan.hasNext()) { n = scan.nextInt(); m = scan.nextInt(); int[] peoples = new int[n]; for (int i = 0; i < peoples.length; i++) { peoples[i] = 0; } int[] fails = new int[n]; int c = 0; int step = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (peoples[step] == 0) { step++; if (step >= n) { step = 0; } } else { j--; step++; if (step >= n) { step = 0; } } } int tempor = step - 1; if (tempor < 0) { tempor = n - 1; } fails[c++] = tempor + 1; peoples[tempor] = 1; } for (int i = 0; i < fails.length - 1; i++) { System.out.print(fails[i] + "\t"); } System.out.println(); System.out.print(fails[n - 1]); } }}
点赞 回复 分享
发布于 2019-04-13 16:45

相关推荐

不愿透露姓名的神秘牛友
02-12 10:05
小米集团 算法工程师 28.0k*15.0
泡沫灬一触即破:楼上那个看来是看人拿高薪,自己又不如意搁这泄愤呢是吧,看你过往评论很难不怀疑你的精神状态
点赞 评论 收藏
分享
2024-12-29 15:37
已编辑
西华大学 图像识别
程序员牛肉:去不了,大厂算法卡学历吧
点赞 评论 收藏
分享
01-26 18:45
门头沟学院 Java
一天代码十万三:哥们实习再包一下吧,产出太笼统了,尽量体现业务
点赞 评论 收藏
分享
评论
点赞
5
分享

创作者周榜

更多
牛客网
牛客企业服务