java第一次作业

1.

package homework;

public class test2 {
  public static void main(String[] args) {
    System.out.println("计算机1904陈玉林");
  }
}

2.

package homework;

public class test1 {
  public static void main(String[] args) {
  int n = 3;
  for (int i = 1; i <= n; i++) {
    for (int k = n - 1; k >= i; k--) {
      System.out.print(" ");
    }
    for (int j = 1; j <= 2 * i - 1; j++) {
      System.out.print("*");
    }
      System.out.println();
  }
  for (int i = n - 1; i >= 1; i--) {
    for (int k = i; k <= n - 1; k++) {
      System.out.print(" ");
    }
    for (int j = 1; j <= 2 * i - 1; j++) {
      System.out.print("*");
    }
      System.out.println();
  }  

  }

}

3.

package homework;

public class test3 {
  public static void main(String[] args) {
  int a = 5;
  int b = 8;
  System.out.println(a*a+b*b);
  }
}

posted on 2021-03-07 19:52  chenyulin11  阅读(37)  评论(0编辑  收藏  举报

导航