Erlang 0049 哈哈,一起來列印三角形

2021-06-08 23:22:36 字數 2551 閱讀 4678

先來個簡單的,首先想到的是使用string:right/2的格式化方法,本來是想省事的,實際上不用更簡單,我的答案如下:

是不是不用string:right/2更簡單?

拋磚引玉了,你有更簡單的方法麼?

p.s 附贈乙個九九乘法表列印

6> [begin l =lists:seq(1,9),lists:foreach(fun(n) -> io:format("

~p x ~p = ~p;

",[n,x,n*x]) end ,l),io:format("

~n") end || x

1 x 1 = 1

;2 x 1 = 2; 3 x 1 = 3; 4 x 1 = 4; 5 x 1 = 5; 6 x 1 = 6; 7 x 1 = 7; 8 x 1 = 8; 9 x 1 = 9;

1 x 2 = 2

;2 x 2 = 4; 3 x 2 = 6; 4 x 2 = 8; 5 x 2 = 10; 6 x 2 = 12; 7 x 2 = 14; 8 x 2 = 16; 9 x 2 = 18;

1 x 3 = 3

;2 x 3 = 6; 3 x 3 = 9; 4 x 3 = 12; 5 x 3 = 15; 6 x 3 = 18; 7 x 3 = 21; 8 x 3 = 24; 9 x 3 = 27;

1 x 4 = 4

;2 x 4 = 8; 3 x 4 = 12; 4 x 4 = 16; 5 x 4 = 20; 6 x 4 = 24; 7 x 4 = 28; 8 x 4 = 32; 9 x 4 = 36;

1 x 5 = 5

;2 x 5 = 10; 3 x 5 = 15; 4 x 5 = 20; 5 x 5 = 25; 6 x 5 = 30; 7 x 5 = 35; 8 x 5 = 40; 9 x 5 = 45;

1 x 6 = 6

;2 x 6 = 12; 3 x 6 = 18; 4 x 6 = 24; 5 x 6 = 30; 6 x 6 = 36; 7 x 6 = 42; 8 x 6 = 48; 9 x 6 = 54;

1 x 7 = 7

;2 x 7 = 14; 3 x 7 = 21; 4 x 7 = 28; 5 x 7 = 35; 6 x 7 = 42; 7 x 7 = 49; 8 x 7 = 56; 9 x 7 = 63;

1 x 8 = 8

;2 x 8 = 16; 3 x 8 = 24; 4 x 8 = 32; 5 x 8 = 40; 6 x 8 = 48; 7 x 8 = 56; 8 x 8 = 64; 9 x 8 = 72;

1 x 9 = 9

;2 x 9 = 18; 3 x 9 = 27; 4 x 9 = 36; 5 x 9 = 45; 6 x 9 = 54; 7 x 9 = 63; 8 x 9 = 72; 9 x 9 = 81;

一起來學習Ant Design

當然,都屬於webpack中的基礎知識,但是套上了atool build這樣乙個殼子,又有點小懵。還好不是很難,嘗試後,很快搞定了,順手也總結一下吧!一 安裝ant init 1 npm install antd init g 二 建立目錄 1 mkdir antd demo cd antd dem...

一起來存方法

1.在動態渲染元素的時候,需要邏輯判斷 在迴圈渲染dom元素時,迴圈遍歷中需要邏輯操作,如果不使用模板 1 var addlist function 7 if 條件2 10lists.push list 11 12 id html lists.join 13 這是在看一同事 時,發現她用push和j...

一起來挑戰Google code jam 一

給你兩個陣列va和vb,兩個陣列的元素對應相乘,然後求和,要求和最小,在陣列元素順序可以調整的時候。這裡主要用到乙個不等式,x和y兩個公升序的陣列,那麼sum x i y i sum x i y n i void fun printf d n res 題意是給你一排p個牢房,最初的時候每個牢房中有乙...