Programming/C C++
Print the Elements of a Linked List
ElAsJay
2020. 8. 16. 02:01
728x90
https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list/problem
/*
* For your reference:
*
* SinglyLinkedListNode {
* int data;
* SinglyLinkedListNode* next;
* };
*
*/
void printLinkedList(SinglyLinkedListNode* head) {
SinglyLinkedListNode *node=head;
while(node!=NULL){
printf("%d\n",node->data);
node=node->next;
}
}
△ 작성한 부분
연결 리스트의 원소들의 값을 출력하는 함수로, 해당 노드의 값이 NULL이 되기 전까지 연결 링크를 따라 쭉 데이터값을 출력하면 된다.
SMALL