gpt4 book ai didi

C编译错误: Id returned 1 exit status

转载 作者:太空狗 更新时间:2023-10-29 17:13:56 29 4
gpt4 key购买 nike

出于某种原因,当我尝试编译程序时,编译器提示权限被拒绝并且 Id 返回 1 退出状态。谁能告诉我这是什么意思?谢谢

#include <stdio.h>                                               /* Library inclusions */
#include "genlib.h"
#include "simpio.h"

int binSearch(int val, int numbers[], int size1); /* prototypes */
void sortArray (int numbers[], int size1);
int indexMax (int numbers[], int low, int high);
void swap (int numbers[], int loc, int loc1);
void getArray (int numbers[], int size1);
void displayArray (int numbers[], int size1);

main()
{
int value, size1;

printf("Enter the number of elements: ");
size1=GetInteger();
int numbers[size1];
getArray(numbers, size1);
sortArray(numbers, size1);
displayArray(numbers, size1);
printf("\nEnter value to find: ");
value=GetInteger();
binSearch(value, numbers, size1);
getchar();
}

void sortArray (int numbers[], int size1) /*Function sortArray*/
{
int i , maxInd;

for (i= size1-1; i>=0;i--)
{
maxInd=indexMax(numbers, 0, i);
swap (numbers, i, maxInd);
}
}

void displayArray (int numbers[], int size1) /*Function displayArray*/
{
int i;

printf("This is the sorted set of numbers: \n");
for (i=0; i< size1; i++)
{
printf ("%d\t", numbers[i]);
}
}

void getArray (int numbers[], int size1) /*Function getArray*/
{
int i;

for (i=0; i<size1; i++)
{
printf ("Enter the values of the %d elements: ", size1);
numbers[i]=GetInteger();
}
}

int indexMax (int numbers[], int low, int high) /*Function indexMax*/
{
int i, maxInd;

maxInd=high;
for (i=low;i<=high;i++)
{
if (numbers[i]>numbers[maxInd])
{
maxInd =i;
}
}
return (maxInd);
}

void swap (int numbers[], int loc, int loc1) /*Function swap*/
{
int temp;

temp=numbers[loc];
numbers[loc]=numbers[loc1];
numbers[loc1]=temp;
}

int binSearch(int val, int numbers[], int size1) /*Function binSearch*/
{
int low, high, mid;

low=0;
high=size1-1;
while(low<=high)
{
mid=(low+high)/2;
if(val<numbers[mid])
{
high=mid-1;
}
else if(val>numbers[mid])
{
low=mid+1;
}
else if(val==numbers[mid])
{
printf("Your number is in location %d\n", mid+1);break;
}
else
{
printf("Your value is not in the array.");
}
}
}

以上是我尝试编译的二分查找算法代码。

最佳答案

我猜,您的程序的旧实例仍在运行。 Windows 不允许更改当前“正在使用”的文件,并且您的链接器无法在正在运行的文件的顶部写入新的 .exe。尝试停止/终止您的程序。

关于C编译错误: Id returned 1 exit status,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17717946/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com