image.png

    1. //1.1.3
    2. import java.util.Scanner;
    3. public class Test
    4. {
    5. public static void main(String[] args)
    6. {
    7. Scanner input = new Scanner(System.in);
    8. int a = input.nextInt();
    9. int b = input.nextInt();
    10. int c = input.nextInt();
    11. if (a == b && b == c)
    12. {
    13. System.out.println("equal");
    14. }
    15. else System.out.println("not equal");
    16. }
    17. }

    image.png

    1. //1.1.5
    2. import java.util.Scanner;
    3. public class Test
    4. {
    5. public static void main(String[] args)
    6. {
    7. Scanner input = new Scanner(System.in);
    8. double x = input.nextDouble();
    9. double y = input.nextDouble();
    10. if ((x >= 0 && x <= 1) && (y >= 0 && y <= 1))
    11. {
    12. System.out.println(true);
    13. }
    14. else
    15. System.out.println(false);
    16. }
    17. }

    image.png

    1. //1.1.9
    2. import java.util.Scanner;
    3. public class Test
    4. {
    5. public static void main(String[] args)
    6. {
    7. Scanner input = new Scanner(System.in);
    8. int N = input.nextInt();
    9. String string = "";
    10. while (N > 0)
    11. {
    12. int r = N % 2;
    13. string = r + string;
    14. N /= 2;
    15. }
    16. System.out.println(string);
    17. }
    18. }

    image.png

    1. //1.1.11
    2. public class Test
    3. {
    4. public static void main(String[] args)
    5. {
    6. boolean[][] a = {{true, true, false},{false, true, false}};
    7. for (int i = 0; i < a.length; ++i)
    8. {
    9. for (int j = 0; j < a[i].length; ++j)
    10. {
    11. if (a[i][j] == true)
    12. System.out.println("第"+i+"行,"+"第"+j+"列:"+"*");
    13. else
    14. System.out.println("第"+i+"行,"+"第"+j+"列:"+" ");
    15. }
    16. }
    17. }
    18. }

    image.png

    1. //1.1.13
    2. import java.util.Arrays;
    3. public class Test
    4. {
    5. public static void main(String[] args)
    6. {
    7. int M = 3;
    8. int N = 2;
    9. int[][] o = {{2,3}, {1,2}, {4,5}};
    10. int[][] n = new int[N][M];
    11. for (int i = 0; i < M; ++i)
    12. {
    13. for (int j = 0; j < N; ++j)
    14. {
    15. n[j][i] = o[i][j];
    16. }
    17. }
    18. for (int a = 0; a < 2; ++a)
    19. {
    20. System.out.println(Arrays.toString(n[a]));
    21. }
    22. }
    23. }

    image.png

    1. //1.1.14
    2. public class Test
    3. {
    4. public static void main(String[] args)
    5. {
    6. int a = lg(7);
    7. System.out.println(a);
    8. }
    9. public static int lg(int N)
    10. {
    11. if (N >= 1)
    12. {
    13. int exp = 1;
    14. int x = 0;
    15. while (exp <= N)
    16. {
    17. exp *= 2;
    18. x++;
    19. }
    20. return x - 1;
    21. }
    22. return -1;
    23. }
    24. }

    image.png

    1. //1.1.15
    2. import java.util.Arrays;
    3. public class Test
    4. {
    5. public static void main(String[] args)
    6. {
    7. int[] a = {1, 2, 1, 3, 1};
    8. System.out.println(Arrays.toString(Test.histogram(a, 3)));
    9. }
    10. public static int[] histogram(int[] a, int m)
    11. {
    12. int[] b = new int[m];
    13. for (int i = 0; i < m; ++i)
    14. {
    15. int tick = 0;
    16. for (int num: a)
    17. {
    18. if (num == i + 1)
    19. {
    20. ++tick;
    21. }
    22. b[i] = tick;
    23. }
    24. }
    25. return b;
    26. }
    27. }

    image.png

    1. //1.1.20
    2. public class Test
    3. {
    4. public static void main(String[] args)
    5. {
    6. System.out.println(cal(3));
    7. System.out.println(Math.log(cal(3)));
    8. }
    9. public static int cal(int N)
    10. {
    11. if (N <= 1)
    12. {
    13. return 1;
    14. }
    15. return cal(N - 1) * N;
    16. }
    17. }

    image.png

    1. //1.1.21
    2. import java.util.Scanner;
    3. public class Test
    4. {
    5. public static void main(String[] args)
    6. {
    7. String [] array = new String[100];
    8. int i = 0;
    9. Scanner input = new Scanner(System.in);
    10. while (input.hasNext())
    11. {
    12. array[i] = input.nextLine();
    13. if(array[i].equals("end")){
    14. break;
    15. }
    16. i++;
    17. }
    18. System.out.println();
    19. for (int j = 0; j < i; ++j)
    20. {
    21. String [] strings = array[j].split(" ");
    22. String string1 = strings[0];
    23. int x = Integer.parseInt(strings[1]);
    24. int y = Integer.parseInt(strings[2]);
    25. System.out.printf("%s %d %d %.3f \n", string1, x, y, (double) x / y);
    26. }
    27. }
    28. }

    image.png

    1. //1.1.24
    2. import java.util.Scanner;
    3. public class Test
    4. {
    5. public static void main(String[] args)
    6. {
    7. Scanner input = new Scanner(System.in);
    8. int a = input.nextInt();
    9. int b = input.nextInt();
    10. System.out.println(fun(a, b));
    11. }
    12. public static int fun(int a, int b)
    13. {
    14. if (a % b == 0)
    15. {
    16. return b;
    17. }
    18. System.out.print(a+" ");
    19. System.out.println(b);
    20. return fun(b, a % b);
    21. }
    22. }