← 목록

정보처리기사 실기 2025년 2회

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;
}
댓글…

나만의 풀이, 암기법을 나눠 보세요. 정답이 포함될 수 있어요.

해설
왼쪽에서 보기를 고르고 정답 확인을 누르면
여기에 정답과 해설이 표시됩니다.