Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法将int转换为int。数组C_C_Arrays_Function_Random_Permutation - Fatal编程技术网

无法将int转换为int。数组C

无法将int转换为int。数组C,c,arrays,function,random,permutation,C,Arrays,Function,Random,Permutation,您好,我很难让数组在函数中工作。我一直收到一个名为C2664“void ranNumPerm_10(int)”的错误:无法将参数1从“int[10]”转换为“int”。“我不知道如何修复它…” 函数ranNumPerm_10(int): void ranNumPerm_10(int bubble_1[] { int oneRandno; int haveRand[ARRAY_SIZE_1]={0}; 对于(int i=0;i

您好,我很难让数组在函数中工作。我一直收到一个名为C2664“void ranNumPerm_10(int)”的错误:无法将参数1从“int[10]”转换为“int”。“我不知道如何修复它…”

函数ranNumPerm_10(int):

void ranNumPerm_10(int bubble_1[]
{
int oneRandno;
int haveRand[ARRAY_SIZE_1]={0};
对于(int i=0;i
该程序是一个未完成的程序,将使用冒泡、选择、插入排序算法。我似乎还不能填充数组。我试图通过做一个“随机数排列生成器”来做一个函数,这样每个数都是随机的,没有一个数重复它自己。我需要一些帮助来让代码正常工作并解决错误C2664

完整代码:

#define _CRT_SECURE_NO_WARNINGS
#define ARRAY_SIZE_1 10
#include <stdio.h>
#include <stdlib.h>


void ranNumPerm_10(int bubble_1);

int main(void)
{
    //Declarations
    int bubble_1[ARRAY_SIZE_1];

    //Bubble population @ 10 
    ranNumPerm_10(bubble_1);
    for (int i = 0; i < ARRAY_SIZE_1; i++)
    {
        printf("%d\n", bubble_1[i]);
    }

    printf("Array population test...\n");
    return 0;
} 
    void ranNumPerm_10(int bubble_1[])
{
    int oneRandno;
    int haveRand[ARRAY_SIZE_1] = { 0 };

    for (int i = 0; i < ARRAY_SIZE_1; i++)
    {
        do
        {
            oneRandno = rand() % ARRAY_SIZE_1;
        } while (haveRand[oneRandno] == 1);
        haveRand[oneRandno] = 1;
        bubble_1[i] = oneRandno;
    }
    return;
}
\define\u CRT\u SECURE\u NO\u警告
#定义数组\u大小\u 1 10
#包括
#包括
空位等级10(内部气泡等级1);
内部主(空)
{
//声明
int bubble_1[数组大小_1];
//泡沫人口@10
朗姆佩姆10(气泡1);
对于(int i=0;i
的声明和定义有冲突的签名。在完整代码的顶部,您将其声明为
void(int)
,但随后的定义是
void(int[])

哦,天哪,我真蠢!我花了几个小时思考原型的问题与指针有关。我一直在尝试void(int*)和void(int[*])。我不知道在函数中,如果使用数组,则类型设置为“type[]”。我在原型机中思考,这无关紧要。感谢您的帮助。您还应该得到一个行
void ranNumPerm_10(int bubble_1[])的错误。
#define _CRT_SECURE_NO_WARNINGS
#define ARRAY_SIZE_1 10
#include <stdio.h>
#include <stdlib.h>


void ranNumPerm_10(int bubble_1);

int main(void)
{
    //Declarations
    int bubble_1[ARRAY_SIZE_1];

    //Bubble population @ 10 
    ranNumPerm_10(bubble_1);
    for (int i = 0; i < ARRAY_SIZE_1; i++)
    {
        printf("%d\n", bubble_1[i]);
    }

    printf("Array population test...\n");
    return 0;
} 
    void ranNumPerm_10(int bubble_1[])
{
    int oneRandno;
    int haveRand[ARRAY_SIZE_1] = { 0 };

    for (int i = 0; i < ARRAY_SIZE_1; i++)
    {
        do
        {
            oneRandno = rand() % ARRAY_SIZE_1;
        } while (haveRand[oneRandno] == 1);
        haveRand[oneRandno] = 1;
        bubble_1[i] = oneRandno;
    }
    return;
}