📄 charactergraph.java
字号:
package exercise;
import java.util.*;
public class CharacterGraph {
/**
* @param args
*/
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.print("Please input a positive integer: ");
int n=scanner.nextInt();
System.out.println("Square");
for(int row=0;row<n;row++){
for(int col=0;col<n;col++){
System.out.print("* ");
}
System.out.println();
}
System.out.println("Triangle");
for(int row=0;row<n;row++){
for(int k=n-row-1;k>0;k--){
System.out.print(" ");
}
for(int col=0;col<row+1;col++){
System.out.print("* ");
}
System.out.println();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -