fork download
  1. # sprintf("%4.0i", 1:12) 能讓1:12「都佔四格」且「向右對齊」
  2. n <- 12
  3. for(i in 1:n) {
  4. cat(strrep("*", (n - i)*2))
  5. for (j in 1:n) {
  6. if (i >= j) cat(sprintf("%4.0i", j))
  7. }
  8. cat("\n")
  9. }
  10.  
Success #stdin #stdout 0.24s 38868KB
stdin
Standard input is empty
stdout
**********************   1
********************   1   2
******************   1   2   3
****************   1   2   3   4
**************   1   2   3   4   5
************   1   2   3   4   5   6
**********   1   2   3   4   5   6   7
********   1   2   3   4   5   6   7   8
******   1   2   3   4   5   6   7   8   9
****   1   2   3   4   5   6   7   8   9  10
**   1   2   3   4   5   6   7   8   9  10  11
   1   2   3   4   5   6   7   8   9  10  11  12