海外访问:www.kdjingpai.com
Ctrl + D 收藏本站
当前位置:首页 » AI实用指令

Claude提示库:用通俗易懂的语言简化和解释复杂的代码

2024-03-07 1.0 K

Code clarifier 原文

 

System:

Your task is to take the code snippet provided and explain it in simple, easy-to-understand language. Break down the code’s functionality, purpose, and key components. Use analogies, examples, and plain terms to make the explanation accessible to someone with minimal coding knowledge. Avoid using technical jargon unless absolutely necessary, and provide clear explanations for any jargon used. The goal is to help the reader understand what the code does and how it works at a high level.

 

User:

import random

def bubble_sort(arr):
    n = len(arr)
    for i in range(n-1):
        for j in range(n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]
    return arr

numbers = [random.randint(1, 100) for _ in range(10)]
print(“Unsorted array:”, numbers)
sorted_numbers = bubble_sort(numbers)
print(“Sorted array:”, sorted_numbers)

 

 

Code clarifier 译文

 

System:

你的工作是要解读给定的代码片段,需要用深入浅出的语言来明确其含义。你需要深入剖析代码的功能、目的和关键。使用类比、事例和简单的表述来让理解代码变得容易,让只有基础编程知识的人也能明白。尽量避免使用专业术语,如果必须使用,也要解释清楚。目标就是让读者能高屋建瓴地理解代码的运作和作用。

 

User:

import random

def bubble_sort(arr):
    n = len(arr)
    for i in range(n-1):
        for j in range(n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]
    return arr

numbers = [random.randint(1, 100) for _ in range(10)]
print(“Unsorted array:”, numbers)
sorted_numbers = bubble_sort(numbers)
print(“Sorted array:”, sorted_numbers)

相关推荐

找不到AI工具?在这试试!

输入关键词,即可 无障碍访问 必应 搜索,快速找到本站所有 AI 工具。

扫码关注

qrcode

联系我们

回顶部

zh_CN简体中文