指向下一個節點

直接上代碼:

#include "stdio.h"


struct NODE{


    int value;

    struct NODE *nextNode;

    struct NODE *preNode;

    

};


typedef struct NODE sNODE;


//sNODE NodeBrightness;

//sNODE NodeContrast;

//sNODE NodeSharp;


int main()

{

printf("main\n");


    sNODE NodeContrast = {30, NULL, NULL};

    sNODE NodeSharp = {70, NULL, NULL};

    sNODE NodeBrightness = {50, &NodeContrast, NULL};

    

//  NodeBrightness.nextNode = &NodeContrast;


    NodeContrast.nextNode = &NodeSharp;

    NodeContrast.preNode = &NodeBrightness;

    

    NodeSharp.preNode = &NodeContrast;

    

//    NodeBrightness = {50, &NodeContrast, NULL};

//    NodeContrast = {30, &NodeSharp, NodeBrightness};

//    NodeBrightness = {70, NULL, NodeContrast};

    

    printf("Brightness = %d\n", NodeBrightness.value);

    printf("Contrast = %d\n", NodeContrast.value);

    printf("Sharpness = %d\n", NodeSharp.value);


    printf("Brightness next value = %d\n", NodeBrightness.nextNode->value);


    printf("Contrast next value = %d\n", NodeContrast.nextNode->value);


    printf("Sharpness pre value = %d\n", NodeSharp.preNode->value);

    

    return 0;


}


    Brightness的下一個節點是contrast, contrast的下一個節點是sharpness。

    sharpness的上一個節點是contrast,contrast的上一個節點是Brightness。

    

編譯,運行,輸出爲:

main

Brightness = 50

Contrast = 30

Sharpness = 70

Brightness next value = 30

Contrast next value = 70

Sharpness pre value = 30





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章