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

// 구조체 자체는 poly_node, 포인터 타입은 poly_node_ptr로 재지정
typedef struct poly_node {
    int coef;
    int expon;
    struct poly_node* link; 
} poly_node, *poly_node_ptr; // poly_node_ptr는 (struct poly_node*)와 같습니다.

// 노드 생성 함수
poly_node_ptr create_node(int coef, int expon) {
    // struct poly_node* 대신 재지정된 포인터 타입을 사용하여 간결하게 할당
    poly_node_ptr newNode = (poly_node_ptr)malloc(sizeof(poly_node));
    newNode->coef = coef;
    newNode->expon = expon;
    newNode->link = NULL;
    return newNode;
}

int main() {
    // P = 3x^9 + 2x^4 + 1 생성
    poly_node_ptr head = create_node(3, 9);
    head->link = create_node(2, 4);
    head->link->link = create_node(1, 0);

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: