程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> 鏈表-c語言編譯 出現error C2061 和error C2059

鏈表-c語言編譯 出現error C2061 和error C2059

編輯:編程綜合問答
c語言編譯 出現error C2061 和error C2059

圖片說明

不知道為什麼一直出現說我標識符有問題的提示,我看了下以前編的程序,好像也是這樣寫法的啊,不知這次怎麼會這樣。求各位大神相助。

 #include <stdio.h>
#include <stdlib.h> 

struct Jihe{
    char nodeSet;
    struct Jihe* next;
};

bool Initiate(struct Jihe** head){
    *head = (struct Jihe*)malloc(sizeof(struct Jihe));
    (*head)->next = NULL;
    return 1;
}

bool RecordSet(struct Jihe* head,char text[]){
    struct Jihe* set = head;
    int i = 0;
    while(text[i] != '\0'){
        set->next = (struct Jihe*)malloc(sizeof(struct Jihe));
        set->next->nodeSet = text[i];
        i++;
        set = set->next;
    }
    set->next = NULL;
    RankSet(&head);
    return 1;
}

bool GetAnd(struct Jihe* head1,struct Jihe* head2,struct Jihe** result){
    struct Jihe *set1 = head1,*set2 = head2,*set3 = *result;
    while(set1->next != NULL && set1->next->next != NULL){
        set3->next = (struct Jihe*)malloc(sizeof(struct Jihe));
        set3->next->nodeSet = set1->next->nodeSet;
        set3 = set3->next;
        set1 = set1->next;
    }
    while(set2->next->next != NULL){
        set3->next = (struct Jihe*)malloc(sizeof(struct Jihe));
        set3->next->nodeSet = set2->next->nodeSet;
        set3 = set3->next;
        set2 = set2->next;
    }
    set3->next = NULL;
    RankSet(result);
    return 1;
}

bool GetCross(struct Jihe** head1,struct Jihe** head2){
    return 1;
}

bool GetDiffer(struct Jihe** head1,struct Jihe** head2){
    return 1;
}

bool RankSet(struct Jihe** head){
    char rankSet[20] = {0};
    int i = 0 ,j = 0,len = 0;//len記錄集合大小
    int small = 0, move;//move是用來刪除元素的;
    char temp;
    struct Jihe* set = *head;
    struct Jihe* newSet = NULL;
    if(set == NULL){
        printf("空鏈表\n");
        return 0;
    }
    while(set->next != NULL && set->next->next != '\0'){
        rankSet[i] = set->next->nodeSet;
        set = set->next;
        len++;
    }

    for(i = 0;i < len; i++){
        for(j = i+1;j < len;j++){
            //刪除子串中相同的元素
            if(rankSet[i] == rankSet[j]){
                //當這個元素為最後一個時,將終止符前移
                for(move = j; move <= len-1; move++){
                    rankSet[move] = rankSet[move+1]; 
                }
                len--;
            }
            if((rankSet[small] > rankSet[j]) && rankSet[j] != '\0' )
                small = j;
        }
        if(rankSet[small] == '\0')
            break;
        temp = rankSet[small];
        rankSet[small] = rankSet[i];
        rankSet[i] = temp;
    }
    newSet = (struct Jihe*)malloc(sizeof(struct Jihe));
    head = &newSet;
    for(i = 0;i < len;i++){
        newSet->next = (struct Jihe*)malloc(sizeof(struct Jihe));
        newSet->next->nodeSet = rankSet[i];
        newSet = newSet->next;
    }
    newSet->next = NULL;
    return 1;
}

bool GetSet(struct Jihe* head,char nowSet[]){
    struct Jihe*p = head;
    int i = 0;
    nowSet = {0};
    while(p->next != NULL && p->next->next != NULL){
        nowSet[i] = p->next->nodeSet;
        p = p->next;
        i++;
    }
    return 1;
}





void main(){
    struct Jihe *set1;
    struct Jihe *set2;
    struct Jihe *result;
    char text[20] = {0};
    Initiate(&set1);
    Initiate(&set2);
    Initiate(&result);
    printf("Set1 = :");
    scanf("%s",text);
    RecordSet(set1,text);
    printf("Set2 = ");
    scanf("%s",text);
    RecordSet(set2,text);
    printf("Set1 ∪ Set2 = ");


}

最佳回答:


返回類型不行。或許是c語言沒有bool型(忘了到底有沒有了),該為int就沒事了

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved