정보처리기사 실기 · 2025년 2회 · 15번

Q.152025년2회9과목 · C언어배점 5점
아래 코드의 출력값을 작성하시오.
#include <stdio.h>
#include <stdlib.h>
struct node { char c; struct node* p; };
struct node* func(char* s){
    struct node* h=NULL, *n;
    while(*s){
        n = malloc(sizeof(struct node));
        n->c = *s++; n->p = h; h = n;
    }
    return h;
}
int main(){
    struct node* n = func("BEST");
    while(n){
        putchar(n->c);
        struct node* t = n; n = n->p; free(t);
    }
    return 0;
}

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

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