왜 답이 312…
null은 뒤에 있는데 왜 안 씀?
1,null이면 next 쓰면 1이 왜 나옴? null나오면 안 됨?
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;
}
}
왜 답이 312…
null은 뒤에 있는데 왜 안 씀?
1,null이면 next 쓰면 1이 왜 나옴? null나오면 안 됨?
모든 문제들의 저작권은 원저작권자에게 있습니다. 본 사이트는 웹상에 공개되어 있는 문제만 모아서 보여드립니다.
저작권 안내 데이터 보호 안내 제휴 문의
copyright 2026 뉴비티::새로운 CBT 시스템 - newbt.kr (Listed on LeanVibe)