1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| const readline = require('readline') const rl = readline.createInterface({ input:process.stdin, output:process.stdout })
rl.on("line",(res)=>{ main(parseInt(res)) })
function main(n){ let m= Array(2*n-1).fill(0).map(item=> Array(2*n-1).fill(0) ); for (let i = 0; i < 2*n-1; i++) { m[i][i]=1 m[i][2*n-2-i]=1 m[n-1][i]=1 m[i][n-1]=1 if(i<n){ m[0][2*n-2-i]=1 m[i][0]=1 m[2*n-2][i]=1 m[n-1+i][2*n-2]=1 } } for (let i = 0; i < 2*n-1; i++) { for (let j = 0; j < 2*n-1; j++) { if(m[i][j]){ process.stdout.write("*") }else{ process.stdout.write(" ") } } console.log() } } main(3)
|