아래 코드의 출력값을 작성하시오.
#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;
}댓글1개
나만의 풀이, 암기법을 나눠 보세요. 정답이 포함될 수 있어요.
해설
왼쪽에서 보기를 고르고 정답 확인을 누르면
여기에 정답과 해설이 표시됩니다.
여기에 정답과 해설이 표시됩니다.
꿈라CBT