gpt4 book ai didi

编译错误说 "conflicting types for ‘check’ “

转载 作者:行者123 更新时间:2023-11-30 21:00:51 27 4
gpt4 key购买 nike

 /**
* Return an array of arrays of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().
*/

struct node{
char data[3];
struct node* next;
};
int** threeSum(int* nums, int numsSize, int* returnSize) {
int i,j,k;
struct node* head=NULL;
struct node* current=NULL;
struct node* temp=NULL;
for(i=0;i<numsSize-2;i++){
for(j=i+1;j<numsSize-1;j++){
for(k=j+1;k<numsSize;k++){
if((nums[i]+nums[j]+nums[k])==0){
**bool ans=check(&nums[i],&nums[j],&nums[k],head);**
if(ans==false){
temp=(struct node*)malloc(sizeof(struct node));
temp->data[0]=nums[i];
temp->data[1]=nums[j];
temp->data[2]=nums[k];
temp->next=NULL;
if(head==NULL){
head=temp;
current=head;
}
else{
current->next=temp;
current=temp;
}
}
else if(ans==true){
continue;
}
}
}
}
}
return head;
}

**bool check(int a,int b,int c,struct node* head){**
while(head!=NULL){
if(head->next[0]==a && head->next[1]==b && head->next[2]==c){
return false;
}
else{
return true;
}
head=head->next;
}
}

我想我在这里遗漏了一些关于引用参数的内容

最佳答案

根据 check() 的定义,您只需传递值而不是指向 check() 的指针。排队

bool ans=check(&nums[i],&nums[j],&nums[k],head);
//-------------^

删除 nums[i] 等的 &

关于编译错误说 "conflicting types for ‘check’ “,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38389550/

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