AcWing 3169. 等腰三角形
原题链接
简单
作者:
Latterdays
,
2021-04-17 11:28:25
,
所有人可见
,
阅读 407
java 代码
import java.util.Scanner;
import java.util.*;
import java.util.concurrent.ScheduledExecutorService;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n =sc.nextInt();
char[][] cc = new char[n+1][2*n];
String ss = "";
for (int i = 1; i < 4*n-1; i++) {
ss += i+"";
}
char[] c = ss.toCharArray();
int tem = 0;
for (int i = 1; i <=n ; i++) {
for (int j = 1; j <=n+i-1 ; j++) {
cc[i][j] = '.';
}
}
for (int i = 1; i <=n-1 ; i++) {
cc[i][n-i+1] = c[tem++];
}
for (int i = 1; i <=2*n-2 ; i++) {
cc[n][i] = c[tem++];
}
for (int i = n; i >=2 ; i--) {
cc[i][i+n-1] = c[tem++];
}
for (int i = 1; i <=n ; i++) {
for (int j = 1; j <=n+i-1 ; j++) {
System.out.print(cc[i][j]);
}
System.out.println();
}
}
}