자료구조 리스트 연산 함수들
- 최초 등록일
- 2019.11.11
- 최종 저작일
- 2019.09
- 5페이지/ 한컴오피스
- 가격 1,000원
소개글
"자료구조 리스트 연산 함수들"에 대한 내용입니다.
목차
visual stdio
본문내용
< 소스 코드 >
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <time.h>
typedef struct _Linked Linked;
struct _Linked
{
int Data;
Linked* Next;
};
//리스트 데이터 추가 함수
Linked* fn_Add(Linked** Top, int Data)
{
Linked* tData = (Linked*)malloc(sizeof(Linked));
tData->Data = Data;
tData->Next = NULL;
if (*Top == NULL)
{
*Top = tData;
return *Top;
}
Linked* pre = NULL;
Linked* This = *Top;
while (This != NULL)
{
if (This->Data >= Data)
{
if (This == *Top)
{
tData->Next = *Top;
*Top = tData;
return *Top;
}
else
{
tData->Next = This;
pre->Next = tData;
return *Top;
}
}
pre = This;
This = This->Next;
}
pre->Next = tData;
return *Top;
}
참고 자료
없음