C언어주석좀달아주세요
개랑
C언어 주석좀달아주세요ㅠ
#include stdio.h {/* 기본 입출력 함수가 저장된 헤더파일 */
#include stdlib.h
#include string.h
1
typedef struct listNode {
char data[5];
struct listNode* link;
} listNode;
typedef struct {
listNode* head;
} linkedList_h;
linkedList_h* createLinkedList_h(void);
void freeLinkedList_h (linkedList_h*);
void addLastNode (linkedList_h*, char*);
void reverse (linkedList_h*, char*);
void deleteLastNode (linkedList_h*);
void printList (linkedList_h*);
linkedList_h * createLinkedList_h(void) { /*공백 리스트를 만듦 */
linkedList_h* L;
L = (linkedList_h *)malloc(sizeof(linkedList_h));
L-head = NULL;
return L;
}
void addLastNode (linkedList_h* L, char* x) { /* 알고리즘 3.2의 구현 */
listNode* newNode;
listNode* p;
newNode = (listNode *)malloc(sizeof(listNode));
strcpy(newNode-data, x);
newNode-link = NULL;
if (L-head == NULL) {
L-head = newNode;
return;
}
p = L-head;
while (p-link != NULL) {
p = p-link;
}
p-link = newNode;
}
void reverse(linkedList_h* L){/* 알고리즘 3.4의 구현 */
listNode*p;
listNode* q;
listNode* r;
p = L-head;
q = NULL;
r = NULL;
while (p != NULL) {
r = q;
q = p;
p =p-link;
q-link = r;
}
L-head = q;
}
void deleteLastNode(linkedList_h* L) {/* 프로그램 3.2 */
listNode* previous;
listNode* current;
if (L-head == NULL) return;
if (L-head-link == NULL) {
free(L-head);
L-head = NULL;
return;
}
else {
previous = L-head;
current = L-head-link;
while (current-link != NULL) {
previous = current;
current = current-link;
}
free(current);
previous-link = NULL;
}
}
void freeLinkedList_h(linkedList_h* L) {
listNode* p;
while(L-head !=NULL) {
p = L-head;
L-head = L-head-link;
free(p);
p = NULL;
}
}
void printList(linkedList_h* L) {/*프로그램 3.3*/
listNode* p;
printf(();
p = L-head;
while (p !=NULL) {
printf(%s, p-data);
p = p-link;
if (p !=NULL) {
printf(,);
}
}
}
int main() {
linkedList_h*L;
L = createLinkedList_h();/*공백 리스트 L= ()를 생성*/
addLastNode(L, Kim);/*리스트 L = (Ki L = (Kim,Lee,Park)을 생성*/
addLastNode(L, Lee);
addLastNode(L, Park);
printList(L);/*(Kim, Lee, Park)을 출력 */
addLastNode(L, Yoo);/*원소 Yoo를 리스트 끝에 첨가*/
printList(L);/*(Kim, Lee, Park, Yoo)를 출력*/
deleteLastNode(L);/*마지막 원소를 삭제 */
printList(L);/*(Kim, Lee, Park)을 출력 */
reverse(L);/*리스트 L을 역순으로 변환 */
printList(L);/*(Park, Lee, Kim)을 출력*/
freeLinkedList_h(L);/*리스트 L을 해제 */
printList(L);/*공백 리스트 ()을 출력 */
return 0;
}
-
악당
인간적으로 주석은 본인이 다시는 것이 인생에 도움이 될텐데요...
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692374 | 고수님들 댓글 마니부탁해요!!! (2) | 엄지 | 2025-04-22 |
2692343 | scnaf에 자꾸 선언을 참조하라는데;; (8) | 도래 | 2025-04-22 |
2692282 | 도스상에서 생성된 exe파일에 press~ 뜨게 하기 (4) | 회사원 | 2025-04-21 |
2692256 | scanf("%*c"); ㅠㅠ 고수님들 | 거북이 | 2025-04-21 |
2692230 | 하노이탑 질문입니다. (1) | 미쁘다 | 2025-04-21 |
2692210 | 정보 올림피아드 문제인데.. 풀이 과정이 궁금합니다.(재귀함수) (5) | 물티슈 | 2025-04-20 |
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |