程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Application of bubbling method in program thought in advanced scl programming in python and 1200PLC

編輯:Python
Bubble Sort: It is an algorithm in the field of computer science.headerThe name of the algorithm comes from the fact that when the algorithm is executed, the smaller elements will slowly "float" to the top of the sequence (in ascending or descending order) through the exchange, just as the bubbles of carbon dioxide in carbonated drinks will eventually float to the top of the sequence.The top is the same, so it is called "bubble sort".header--------------------------------------------------------------------------------------------------------One, sorting in python1. Sort data size in a list in python2. Sorted results

2. Sort by SCL in Siemens 1200PLC
1. In 1200PLC, sort the indefinite-length array, and the data type of indeterminate-length array can only be built on the InOut pin

2. Create an arbitrary number of Array type integer data type variables, after runningThe result of

Three, summary
1, twoThe ideas are the same.They all exchange positions through cyclic comparison, and push the data features to the end, or it can be the first.
2. In terms of specific implementation, python uses the While loop and the len() method to get the number of loop rounds and the number of comparisons; scl uses FOR loop, LOWER_BOUND() and UPPER_BOUND() to determine the lower limit and upper limit of the comparison array, and then select the first one in the outer loop and compare them one by one in the inner loop.
4. Extension: Use the existing functions in scl to find the maximum and minimum values ​​in the array
1. To find the maximum and minimum values ​​for a fixed-length Array, you can directly use the FC function block

2. Running result

3. Improve, find the maximum and minimum values ​​for Arrays of variable length

4. The modified scl uses the Upper limit of the Static pin, so the FB function block is used.

5. Running result


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved