티스토리 뷰
List.h
#if !defined(AFX_LIST_H__1AAF7FC2_D6C4_4EB1_9396_379E52798202__INCLUDED_)
#define AFX_LIST_H__1AAF7FC2_D6C4_4EB1_9396_379E52798202__INCLUDED_
#define AFX_LIST_H__1AAF7FC2_D6C4_4EB1_9396_379E52798202__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif// _MSC_VER > 1000
#pragma once
#endif// _MSC_VER > 1000
struct sNODE
{
{
int nData;
sNODE *pNext;
};
sNODE *pNext;
};
class CList
{
public:
{
public:
CList();
virtual ~CList();
virtual ~CList();
void Insert(int nData);
int GetAt(int nIndex);
// void Print(int nIndex);
// int Find(int nData);
int GetCount();
int Delete();
int GetAt(int nIndex);
// void Print(int nIndex);
// int Find(int nData);
int GetCount();
int Delete();
private:
sNODE *m_pHead,
*m_pTail;
};
sNODE *m_pHead,
*m_pTail;
};
#endif // !defined(AFX_LIST_H__1AAF7FC2_D6C4_4EB1_9396_379E52798202__INCLUDED_)
List.cpp
// List.cpp: implementation of the CList class.
//////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "List.h"
//////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "List.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CList::CList()
{
m_pHead = NULL;
m_pTail = NULL;
{
m_pHead = NULL;
m_pTail = NULL;
m_pHead = new sNODE;
m_pTail = new sNODE;
m_pTail = new sNODE;
m_pHead->pNext = m_pTail;
m_pTail->pNext = NULL;
}
m_pTail->pNext = NULL;
}
CList::~CList()
{
{
}
void CList::Insert(int nData)
{
sNODE *pNewnode;
pNewnode = new sNODE;
{
sNODE *pNewnode;
pNewnode = new sNODE;
pNewnode->nData = nData;
pNewnode->pNext = m_pHead->pNext;
m_pHead->pNext = pNewnode;
}
m_pHead->pNext = pNewnode;
}
int CList::GetCount()
{
sNODE *pNode;
int nCount = 0;
pNode = m_pHead;
while(pNode->pNext != NULL)
{
pNode = pNode->pNext;
++nCount;
}
{
pNode = pNode->pNext;
++nCount;
}
return (nCount-1);
}
int CList::Delete()
{
if(GetCount == 0)
return false;
{
if(GetCount == 0)
return false;
sNODE *pNode;
pNode = m_pHead;
pNode = pNode->pNext;
pNode = m_pHead;
pNode = pNode->pNext;
m_pHead->pNext = pNode->pNext;
delete pNode;
return true;
}
}
main.cpp
#include <stdio.h>
#include "List.h"
#include "List.h"
void main()
{
CList List;
{
CList List;
List.Insert(5);
List.Insert(12);
List.Insert(3);
List.Insert(9);
List.Insert(12);
List.Insert(3);
List.Insert(9);
printf("Count %d\n", List.GetCount());
}
}
Result
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- NDS
- 3분 영어 위클리
- C/C++
- oracle
- CNN Student News
- 2011사진공모전
- 야생의 숨결
- 아이폰
- Spore
- 가을
- 슈퍼마리오 RPG
- 젤다의 전설
- NDSi
- Free Coupon
- jsp
- 군대이야기
- 동유럽
- 겨울
- Wii GAME
- ndsl
- NDS GAME LIST
- DLC
- 오라클
- 스포어
- 티스토리달력2010
- 티스토리달력2011
- Project Diet
- 동물의숲
- 게시판
- 웃기는 사진
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함