Closed Chenjiangwen closed 1 year ago
example: the code generated by chatGPT:
def bubble_sort(arr):
n = len(arr)
for i in range(n - 1):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
arr = [64, 34, 25, 12, 22, 11, 90]
sorted_arr = bubble_sort(arr)
print("result:", sorted_arr)
but using 'copy' or 'insert in editor', the code will be:
def bubble_sort(arr):
n = len(arr)
for i in range(n-1):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]: <--------
arr[j], arr[j+1] = arr[j+1], arr[j]
return arr
arr = [64, 34, 25, 12, 22, 11, 90]
sorted_arr = bubble_sort(arr)
print("result:", sorted_arr) <--------
Thanks, In my tests, copying does not work, but Insert to Editor is fine. It will be fixed in a later version.
In the code generated by chatGPT, using copy or insert to editor, the symbols: >, <, and ' ' will be converted to & gt;' '& lt;' '& quot;' in the editor.