我有一个list
个对象,比如
[a1 , a2, a3, a4, a5, b1, b2, b3, b4, c1, c2, c3, d1, d2, e1]
必须像
一样打印a1
a2 b1
a3 b2 c1
a4 b3 c2 d1
a5 b4 c3 d2 e1
使用2个for-loops?
答案 0 :(得分:1)
如果初始数据是float y = recyclerView.getY() + recyclerView.getChildAt(selectedPosition).getY();
scrollView.smoothScrollTo(0, (int) y);
(' v1'),我们可以根据频率创建vector
(' m1')空白用字母替换下三角形(matrix
)。
lower.tri
n<- max(table(sub("\\d+", "", v1)))
m1 <- matrix("", ncol=n, nrow=n)
m1[lower.tri(m1, diag=TRUE)] <- v1
m1
# [,1] [,2] [,3] [,4] [,5]
#[1,] "a1" "" "" "" ""
#[2,] "a2" "b1" "" "" ""
#[3,] "a3" "b2" "c1" "" ""
#[4,] "a4" "b3" "c2" "d1" ""
#[5,] "a5" "b4" "c3" "d2" "e1"