谁能告诉我VB中SystemParametersInfo什么意思,怎么用?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了谁能告诉我VB中SystemParametersInfo什么意思,怎么用?相关的知识,希望对你有一定的参考价值。

我们VB实习要利用这个函数自动更改桌面,但我对VB只是懂些皮毛而已,很难编写。。。

应用SystemParametersInfo函数可以获取和设置数量众多的windows系统参数。这个小程序就是运用了SystemParametersInfo函数来设置桌面的墙纸,而且程序可以让我们选择多幅墙纸图片,程序会以一定的时间间隔自动改变墙纸。
我们先来看看SystemParametersInfo函数的定义和参数:
使用API函数之前必须先在程序中声明如下:
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
具体的参见评论|追问

你QQ多少,请教一下

你QQ多少,请教一下

追答

mimi

参考技术A 应用SystemParametersInfo函数可以获取和设置数量众多的windows系统参数。这个小程序就是运用了SystemParametersInfo函数来设置桌面的墙纸,而且程序可以让我们选择多幅墙纸图片,程序会以一定的时间间隔自动改变墙纸。
我们先来看看SystemParametersInfo函数的定义和参数:
使用API函数之前必须先在程序中声明如下:
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
具体的参见
http://blog.csdn.net/theplayerwuliang/article/details/6049934

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

【中文标题】谁能告诉我快速排序代码中的错误是啥【英文标题】: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。

【讨论】:

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

以上是关于谁能告诉我VB中SystemParametersInfo什么意思,怎么用?的主要内容,如果未能解决你的问题,请参考以下文章

VB6 语法问题

通过 vb 脚本连接 Infobright 数据库

VB.NET的API调用

谁能给我一个VB中While语句的实例,我刚入门

vb.net中的SQL事务语句

如何检查 vb .net 项目的 sql server 中是不是存在数据库和表?