2024년 3회 선택하기
정보처리기사 실기 선택하기
12. 아래 코드에서 출력되는 값을 작성하시오.
struct Node {
    int value;
    struct Node* next;  
};

void func(struct Node* node) {
    while (node != NULL && node->next != NULL) {
        int t = node->value;
        node->value = node->next->value;
        node->next->value = t;
        node = node->next->next;
    }
}

int main() {
    struct Node n1 = {1, NULL};
    struct Node n2 = {2, NULL};
    struct Node n3 = {3, NULL};
    
    n1.next = &n3;  
    n3.next = &n2;

    func(&n1);

    struct Node* current = &n1;
    while (current != NULL) {
        printf("%d", current->value);  
        current = current->next;
    }
}

클릭하면 정답이 보입니다.
정답 확인 맞췄어요 O 틀렸어요 X
312
위키 해설 모두가 함께 공부하는 위키해설이란?
문제 풀이
클릭하면 보입니다.
관련 포럼글
자유 댓글

모든 문제들의 저작권은 원저작권자에게 있습니다. 본 사이트는 웹상에 공개되어 있는 문제만 모아서 보여드립니다.
저작권 안내   데이터 보호 안내   제휴 문의

copyright 2025 뉴비티::새로운 CBT 시스템 - newbt.kr