정보처리기사 실기 · 2024년 3회 · 12번

Q.122024년3회9과목 · C언어배점 5점
아래 코드의 출력값을 작성하시오.
#include <stdio.h>
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}, n2={2,NULL}, 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;
    }
    return 0;
}

이 문제는 풀이 화면에서 직접 실행해 풀 수 있어요.

이 회차 문제 풀어보기 →정보처리기사 실기 더 풀기