import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int n = in.nextInt(); for (int i = 0; i < n; i++) { for (int j = n - 1 - i; j >= 0; j--) { // 跟反斜线意思差不多,看打印星星的条件 if (j == 0) { System.out.println("* "); } else { System.out.print(" "); } } } } in.close(); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int n = in.nextInt(); for(int i = 1; i <= n; i++) { //空格 for(int j = n; j > i; j--) { System.out.print(" "); } //符号 System.out.println("*"); } } } }
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextInt()) { // 注意 while 处理多个 case int n = in.nextInt(); for(int i=1;i<=n;i++){ for(int j=n-1;j>=i;j--){ System.out.print(" "); } System.out.println("*"); } } } }
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNextInt()){ int x=sc.nextInt(); int[][] arr=new int[x][x]; for(int i=0;i<x;i++){ arr[i][x-i-1]=1; } for(int i=0;i<x;i++){ for(int j=0;j<x;j++){ if(arr[i][j]==1) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int n = sc.nextInt(); for (int c = 1; c <= n; c++) { for (int a = n-c; a > 0; a--) { //输入一行的空格,第一行有n-1个 System.out.print(" "); } System.out.println("*");//输入一行的* } } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()){ int n = scanner.nextInt(); for(int i = 1 ; i <= n ;i++){ //空格 for(int j = 0;j < n - i ;j++){ System.out.print(" "); } System.out.println("*"); } } } }
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { int a = sc.nextInt(); for(int i=1;i<=a;i++) { for(int j=a;j>=i+1;j--) { System.out.print(" "); } System.out.println("*"); } } } }
import java.util.Scanner; /** * @Title: 正斜线形图案 * @Remark: KiKi学习了循环,BoBo老师给他出了一系列打印图案的练习,该任务是打印用“*”组成的正斜线形图案。 * 输入描述: * 多组输入,一个整数(2~20),表示输出的行数,也表示组成正斜线的“*”的数量。 * 输出描述: * 针对每行输入,输出用“*”组成的正斜线。 * @Author: ijunfu * @Version: 1.0.0 * @Date: 2022-03-20 */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNextLine()) { int count = Integer.parseInt(in.nextLine()); for(int i=1; i<=count; i++) { for(int j=1; j<=count-i; j++) { System.out.print(" "); } System.out.println("*"); } } } }
import java.util.*; public class Main{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); for (int i = 1; i <= n; i++) { for (int j = i; j < n; j++) { System.out.print(" "); } System.out.print("*"); System.out.println(); } } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); for (int i = n; i > 0; i--) { f(i); } } scanner.close(); } static void f(int x) { for (int i = 1; i < x; i++) { System.out.print(' '); } System.out.println('*'); } }
public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(); for(int i=0;i<n;i++){ for(int j=1;j<=n;j++){ if((j+i)==n){ System.out.print("*"); }else{ System.out.print(" "); } } System.out.println(" "); } } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { Integer number = sc.nextInt(); for (int n = 1; n <= number; n++) { for (int s = number-n; s > 0; s--) { System.out.printf(" "); } System.out.println("*"); } } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { int a = sc.nextInt(); for (int i = 0; i < a; i++) { for (int j = i; j < a-1; j++) { System.out.print(" "); } System.out.println("*"); } } } }这是不让java过嘛,我eclipse都能过,就没见通过的代码有java的