/**
* 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;
}
}
「『チェック』の相反するタイプ」を言って:)コンパイルエラー親切.... は、事前にありがとうHELP ~~~~ 私はここに参照パラメータに関する何かが足りないと思う~~~~
ヘッド= head-> nextは決して呼び出されません(これはエラーではありません) –
'threeSum'の実装の上に' check'の実装を移動するか、関数を適切にプロトタイプします。あなたのコンパイラが関数 'check'が' int'を返す「暗黙の宣言」について警告しなかった場合は、あなたの警告レベルをペタニックにする必要があります。 * real *宣言を 'threeSum'で利用できるようにすると、まったく異なるエラー(パラメータ型の不一致)が現れるはずですが、それは別の問題です。 – WhozCraig