40选择题,2道编程题。
1. 第一道编程很简单,根据研究生的四门课入学成绩判断,Fail或Gongfei,Zifei。
import java.util.Scanner;
/**
* Created by aifei on 15/9/15.
*/
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-->0){
int []score = new int[4];
for(int i = 0;
i<4;
i++){
score[i] = sc.nextInt();
}
int sum = score[0] + score[1] + score[2] + score[3];
if(!isFail(score,sum)){
System.out.println("Fail");
}else{
if(sum>=310 && sum<=349){
System.out.println("Zifei");
}else{
System.out.println("Gongfei");
}
}
}
}private static boolean isFail(int[] score,int sum) {
if(score[0]>=60 && score[1]>=60 && score[2]>=90 && score[3]>=90 && sum>=310){
return true;
}else {
return false;
}
}}
2. 素因子分解,并以可视化数字输出素因子。
import java.util.ArrayList;
import java.util.Scanner;
/**
* Created byon 15/9/15.
*/
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
ArrayList list = new ArrayList();
int key = 1;
while(n > 1){
for(int i=2;
i<=n;
i++){
if(n%i==0){
key = i;
list.add(key);
break;
}
}
n = n/key;
}
for(int i=0;
i
【360校园招聘2016笔试题】
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-