谁能告诉我法国朗格勒(langres)的概况?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了谁能告诉我法国朗格勒(langres)的概况?相关的知识,希望对你有一定的参考价值。

参考技术A Langres is a city and commune of eastern France. It is a sous-préfecture of the Haute-Marne département, in the Champagne-Ardenne région.

As the capital of the Romanized Celtic tribe the Lingones, it was called Andematunnum, then Lingones, and now Langres.

The town is built on a limestone promontory of the same name. This stronghold was originally occupied by the Gauls, and, at a later date the Romans fortified the town belonging to the Celtic tribe the Lingones; Andemantunum the strategic cross-roads of twelve Roman roads.fact The 1st century Triumphal Gate and the many artefacts exhibited in the museums are witnesses to the Gallo-Roman town.

After the period of invasions, the town prospered in the Middle Ages due, in part to the growing political influence of its bishops. The diocese covered Champagne, the Duchy of Burgundy and Franche-Comté, and the bishops gained the right to coin money in the 9th century and to name the military governor of the city in 927. The Bishop of Langres was a duke and peer of France. The troubled 14th and 15th centuries were reason enough for the town to strengthen its fortifications, which still give the old part of the city its fortified character, and Langres entered a period of royal tutelage. The Renaissance, which returned prosperty to the town, saw the construction of numerous fine civil, religious and military buildings that still stand today. In the 19th century, a "Vauban" citadel was added.

参考资料:http://www.ville-langres.com/

谁能告诉我快速排序代码中的错误是啥

【中文标题】谁能告诉我快速排序代码中的错误是啥【英文标题】:can anyone tell what's the bug in my quick sort code谁能告诉我快速排序代码中的错误是什么 【发布时间】:2019-03-23 05:09:51 【问题描述】:

谁能告诉我快速排序算法的错误是什么? 我使用两点“左”和“右”与枢轴进行比较,如果当 nums[left] > nums[right] 时交换 nums[left] 和 nums[right]。当左索引大于右索引时,断开并交换 nums[left] 和 nums[piovt],返回左索引。

nums = [3,2,3,1,2,4,5,5,6]
n = len(nums)

def partition(nums,left,right,pivot):
    while left<right:
        if left<right and nums[left]<=nums[pivot]:
            left += 1
        if left<right and nums[right]>=nums[pivot]:
            right -= 1
        elif nums[left]>nums[right]:
            nums[left],nums[right] = nums[right],nums[left]
            left += 1
            right -= 1
    nums[left],nums[pivot] = nums[pivot],nums[left]
    return left

def quicksort(nums,low,high,pivot):
    if low<high:
        pos = partition(nums,low,high,pivot)
        quicksort(nums,low,pos-2,pos-1)
        quicksort(nums,pos+1,high-1,high)
    return nums

quicksort(nums,0,n-2,n-1)

print(nums)

答案:[1, 2, 2, 3, 3, 5, 5, 6, 4]

【问题讨论】:

我的回答有帮助吗? I [swap] nums[left] and nums[right] [when] nums[left] &gt; nums[right] 不需要 pivotadvanve 需要在此摘要中的某个位置进行说明吗?建议:仔细检查 key equals pivot 的处理。 使用nums=[2,1]开始调试 【参考方案1】:

您的代码中有几个错误,我已经为您重写了代码。您可以参考评论并运行一些测试来弄清楚。

import random

# two pointers solution, choose the last one as pivot
def partition(nums, left, right, pivot):
    while left < right:
        # here should change < to <=, because if pivot is larger than all in nums[left:right+1], should swap nums[left] with nums[pivot]
        # here I change if to while, because you should traverse the pointer to find the place which is invalid in partition
        while left <= right and nums[left] <= nums[pivot]:
            left += 1
        # here I change if to while, same reason above
        while left < right and nums[right] > nums[pivot]:
            right -= 1
        # you should not use elif here, because you have two ifs, the first if does not work here
        if left < right:
            nums[left], nums[right] = nums[right], nums[left]
    nums[left], nums[pivot] = nums[pivot], nums[left]
    return left


def quicksort(nums, low, high, pivot):
    if low < high:
        pos = partition(nums, low, high, pivot)
        quicksort(nums, low, pos - 2, pos - 1)
        # here is another problem: notice that nums[pivot] is the last element, not the nums[high]
        quicksort(nums, pos + 1, high, high + 1)
    return nums


if __name__ == '__main__':
    for _ in range(100):
        nums = [random.randrange(1, 100) for _ in range(10000)]
        n = len(nums)
        if sorted(nums) != quicksort(nums, 0, n - 2, n - 1):
            print('incorrect')
    print('success')

我已经尽力帮助你了,希望你喜欢。

【讨论】:

非常感谢!现在我知道为什么我得到了错误的答案,谢谢!【参考方案2】:

要获取数组的中间索引,您应该将快速排序的枢轴设置为整数 n/2。

【讨论】:

除非我理解错了,否则这是不正确的。

以上是关于谁能告诉我法国朗格勒(langres)的概况?的主要内容,如果未能解决你的问题,请参考以下文章

中法DBA项目介绍

红酒aoc和aop的区别

卡巴尔岱:唯一朗格多克AOP法定产区

非常重要读DBA博士,你必须知道的一所精英商校——法国诺曼底管理学院

红酒aop和aoc有啥区别

法国红酒aop是啥等级