發表文章

目前顯示的是 6月, 2020的文章

[python]遞迴跟疊代

break與continue break : 強制結束迴圈 continue : 強制結束這次的迭代 for i in list: break for i in list: continue 基礎while迴圈 while(條件判斷): 程式區塊

[Python] 迴圈

for迴圈搭配list for value in list: print(value) fruits = [ "apple" , "orange" , "banana" , "grape" ] for fruit in fruits : print ( fruit )

[Python] List 的用法

index與count方法 index(內容) : 找到內容所在的索引值 count(內容) : 計算該內容的次數 score = [ 90 , 81 , 70 , 68 , 92 , 70 , 77 , 70 ] print ( "第一個70分的學生是編號 %d 號" % ( int ( score . index ( 70 )) + 1 )) print ( "70分的學生共有 %d 位" % score . count ( 70 )) 第一個70分的學生是編號3號 70分的學生共有3位 in與not in animal = [ "dog" , "cat" , "elephone" , "bird" ] if "dog" in animal : print ( "dog已在串列中" ) else : animal . append ( "dog" ) if "snake" not in animal : animal . append ( "snake" ) print ( "已新增snake" ) else : print ( "snake已在串列中" ) dog已在串列中 已新增snake

[LeetCode] 258. Add Digits

Given a non-negative integer  num , repeatedly add all its digits until the result has only one digit. Example: Input: 38 Output: 2 Explanation: The process is like: 3 + 8 = 11 , 1 + 1 = 2 .   Since 2 has only one digit, return it. Follow up: Could you do it without any loop/recursion in O(1) runtime?

[Java] Array 跟 ArrayList 的區別

Array是Java中的基本功能。 而ArrayList就是Collection Framework的一部分。 因此就有著完全不同的使用方式! 創建方式不同 Array 是一個有固定大小的Array。 每次創建一個新的Array時,都需要為它設定一個大小。 而且在創建後,是不能再更改大小。 int arr[] = new int[10] ArrayList 是一個有浮動大小的Array。 每次創建一個新的Array時,不需要為它設定大小。 因為在創建後,你可以隨意更改它的大小。 另外,它是List interface的實作。 ArrayList arrL = new ArrayList(); 新增元素及存取元素的方式不同 Array透過[]的方式新增元素而ArrayList就透過add()。 Array透過[]的方式存取元素而ArrayList就透過get()。

[Java]Array跟list的用法

 java.util.ArrayList  類提供了可調整大小的數組, 並實現了List接口。以下是關於ArrayList中的要點: 它實現了所有可選的列表操作,並且還允許所有元素,包括空值null。 它提供了一些方法來操作內部用來存儲​​列表的數組的大小。 相較於LinkedList實現的常數因子較低。 ArrayList<資料型態> arrlist = new ArrayList<資料型態>(資料大小) ; //資料大小沒寫代表無限制           ArrayList<String> arrlist = new ArrayList< String >() ;      ArrayList<Integer> arrlist = new ArrayList< Integer >() ;      ArrayList<Boolean> arrlist = new ArrayList<Boolean>() ; 參考來源: http://tw.gitbook.net/java/util/java_util_arraylist.html //判斷矩陣內的數值+額外的數值是否超過矩陣的最大值 如果大於等於 則為 true 反之 false //輸出一個list<boolean> Given the array  candies  and the integer  extraCandies , where  candies[i]  represents the number of candies that the  ith  kid has. For each kid check if there is a way to distribute  extraCandies  among the kids such that he or she can have the  greatest  number of candies among them. Notice that multiple kids can have the  greatest  number of candies.   Example 1: Input: candies = [2,3,5,1,3]

[Java] 數字跟字串轉換

   int n =1234; 方法一:  String str1 = Integer.toString(n);  方法二:  String str3 = String.valueOf(n); 字串轉成矩陣   String[] stringarray = str1.split(""); // stringarray =[1,2,3,4] 字串轉成數字 int index1 = Integer.parseInt(stringarray[0]); ------------------------------------------------------- [LeetCode] 1281 .  Subtract the Product and Sum of Digits of an Integer Given an integer number  n , return the difference between the product of its digits and the sum of its digits.   Example 1: Input: n = 234 Output: 15 Explanation: Product of digits = 2 * 3 * 4 = 24 Sum of digits = 2 + 3 + 4 = 9 Result = 24 - 9 = 15 Example 2: Input: n = 4421 Output: 21 Explanation: Product of digits = 4 * 4 * 2 * 1 = 32 Sum of digits = 4 + 4 + 2 + 1 = 11 Result = 32 - 11 = 21   Constraints: 1 <= n <= 10^5

[Webix] How to define elements of Form

https://snippet.webix.com/6nob96mm $$('movie').define('elements',form3);   $$('movie').reconstruct();

[Python]基礎課程

Python 起源 1991年Python正式誕生 Python底層是由C語言開發的直譯器 Python由Python軟體基金會管理 Python 相較於其他語言優勢 較受歡迎的主流語言 入門檻較低 應用多元 Python 應用的領域 資料科學 人工智慧 開發/管理網站 遊戲開發 .. 目前主流的開發環境 網路開發 Google Colaboratory 本機開發 Anaconda

[SQL] 如何在子查詢中加入排序

其目標是將資料表欄位合併成一個欄位並以,做區隔 例如 [Amy,Bella,Cathy,Dana] A的子查詢中,對姓名做排序 // TOP 2147483647 可以避免子查詢內排序的錯誤 WITH A AS( SELECT TOP 2147483647  * FROM [TB] ORDER BY  name) , //B子查詢分成兩部分,首先先將姓名以,合併 再將最後一個,去除 B AS(  SELECT  DISTINCT      M  .name  ,      left(M. name   ,len(M. name   )-1) as   namelist withoutdot     FROM  (SELECT  name ,(SELECT cast(value AS NVARCHAR ) + ',' from A where  name = ord. name   FOR XML PATH('')) as  namelist   from  A  ord ) M  ) SELECT * FROM B

[編程]快捷鍵

Visual Studio Code Shift+Alt+F = 程式碼快速排版

[webix]時間設定與存取

ui={  view :   "datepicker" ,  id :   "Date"  ,  labelWidth :   35  , format :   "%Y-%m-%d" ,  width :   250 ,  }, var   myformat  =  webix . Date . dateToStr ( "%Y-%m-%d" ); //時間的形式 var   date  =  myformat ( new   Date ()); //當天時間的轉換 $$ ( "Date" ). setValue ( date ); //產生新的時間 webix . Date . add(當天 日期,數量,單位) var   weekdate  =  webix . Date . add ( new   Date (), - 1 ,  "week" ) var   monthdate  =  webix . Date . add ( new   Date (), - 1 ,  "month" ) //修改時間格式 var   weekdate  =  myformat ( webix . Date . add ( new   Date (), - 1 ,  "week" )) var   monthdate  =  myformat ( webix . Date . add ( new   Date (), - 1 ,  "month" )) //取得時間的字串 var daystr= $$ ( 'Date' ). data . text; //day的型態是String //將字串轉成時間 var   day = new   Date ( daystr ); // Thu Jun 04 2020 08:00:00 GMT+0800 (台北標準時間) / 不带new操作符,像一个函数一样调用。它将忽略所有传入的参数,并返回当前日期和时间的一个字符串表示。 new Date (); // 可接受一个数字参数,该参数表示设定时间与1970年1月1日0点之间的毫秒数。

[Webix]如何在Radio選項中預設一個項目

{  view : "radio" , id :   "Radio"  ,  value : 3 ,  options : [ {  id : 1 , value : "Apple"  }, {  id : 2 , value : "Banana"  }, {  id : 3 , value : "ALL"  }  ],  align : "center" ,  width : 280  } 選項用 id 跟value 組成物件 value : 3 代表想要的預設選項