Fuliye intelligent face questions Record Summary:


package LESSON.TEST;

import java.util.Arrays;
public class Test1 {

    static void main public (String [] args) { 
the System. Out.println ( "the Hello World!");
// first test question:
// FizzBuzz (. 9);
// second question test
int [] input = { } 10,20,30,40,50,60;
int n-=. 3;
Fn (iNPUT,. 3);
}
// first title title: enter a number, if it is divisible by 2, the output a, can if divisible by 3, the output B, if both the
// divisible by 2, but also divisible by 3, the output AB,
// answer the first question:
// Analysis: too many times if we directly use if else is determined directly use switch, is performed more efficiently.
public static void FizzBuzz (int X) {
Switch (X%. 6) {
Case 0:
. the System Out.println ( "AB");
BREAK;
Case 2:
the System.Out.println ( "A");
BREAK;
Case. 3:
. the System Out.println ( "B");
BREAK;
}
}

// second question Title:
/// * Given an array, the average split into n sections, each section gives the coordinates of the start and length
// input 10,20,30,40,50,60} {, n = 2
// output {0,3} {3,3}
// input { } 10,20,30,40,50, = n-2
// output} {3,2- 0,3} {
public static void Fn (int [] Array, n-int) {
int [] [] = new new int RES [n-] [2];
int Start = 0;
int len =% n-== 0 be array.length be array.length /n:array.length / n-+. 1;?
int COUNT = 0;
for (int I = 0; I <n-; I ++) {
RES [I] [0] = Start;
RES [I] [. 1] = len;
IF (I-n-==. 1) {
RES [I] [. 1] = -count be array.length ;
}
start += len;
count += len;
}
for(int i=0;i<res.length;i++){
System.out.print(Arrays.toString(res[i])+" ");
}
}
}

Guess you like

Origin www.cnblogs.com/1832921tongjieducn/p/12602594.html