Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- qiskit #
- qiskit #qiskitHackerthon
- qiskit #QuantumComputer #QuantumMachine #양자컴퓨터 #양자 #키스킷
- ibm #qiskit #quantum # quantumcomputer #quantumcomputing #quantummachine #quantumengineering #quantumbit #qbit
Archives
- Today
- Total
인일의 공부 블로그
[C 자료구조] 연결리스트 구현 본문
LinkedRead.c
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
typedef struct _node {
int data;
struct _node * next;
}Node;
int main(void) {
Node *head = NULL;
Node *tail = NULL;
Node *cur = NULL;
Node *newNode = NULL;
int readData;
while (1) {
printf("자연수 입력 : ");
scanf("%d", &readData);
if (readData < 1) {
break;
}
newNode = (Node*)malloc(sizeof(Node));
newNode->data = readData;
newNode->next = NULL;
if (head == NULL) {
head = newNode;
}
else {
tail->next = newNode;
}
tail = newNode;
}
printf("\n");
printf("입력 받은 데이터의 전체 출력! \n");
if (head == NULL) {
printf("저장된 자연수가 존재하지 않습니다. \n");
}
else {
cur = head;
printf("%d ", cur->data);
while (cur->next != NULL) {
cur = cur->next;
printf("%d ", cur->data);
}
}
printf("\n\n");
if (head == NULL) {
return 0;
}
else{
Node *delNode = head;
Node *delNextNode = head->next;
printf("%d를 삭제합니다. \n", head->data);
free(delNode);
while (delNextNode != NULL) {
delNode = delNextNode;
delNextNode = delNextNode->next;
printf("%d를 삭제합니다. \n", delNode->data);
free(delNode);
}
}
system("pause");
return 0;
}
'Language, SDK > C C++' 카테고리의 다른 글
[C언어] 사용자 정의 자료형 (0) | 2021.02.05 |
---|---|
[C언어] 배열과 포인터 (0) | 2021.02.05 |
[C] Pointer 개념정리 (0) | 2021.02.03 |
[C 자료구조] 배열이란 (0) | 2021.01.20 |
[C 자료구조] 배열 기반의 리스트 구현 하나로 묶기 (0) | 2021.01.19 |