~cpp
class Queue
{
enum {Size=100};
private:
int m_nFront;
int m_nRear;
int m_nData[Size];
bool IsEmpty();
bool IsFull();
public:
Queue() {m_nFront=m_nRear=-1;}
bool Add(int ndata);
bool Erase();
void Show();
~Queue() {}
};
bool Queue::IsEmpty()
{
true;
return false;
}
bool Queue::IsFull()
{
if(m_nRear==Size-1 && m_nFront!=m_nRear)
return true;
return false;
}
bool Queue::Add(int ndata)
{
if(!IsFull())
{
m_nData[++m_nRear]=ndata;
return true;
}
else
{
cout<<"κ½μ°Όλ€";
return false;
}
}
bool Queue::Erase()
{
if(!IsEmpty())
{
m_nFront++;
return true;
}
else
{
cout<<"λΉμλ€";
return false;
}
}
void Queue::Show()
{
int count=m_nFront;
while(1)
{
cout<<m_nData[++count];
if(count==m_nRear)
break;
}
}
- κ·Έλ°λ°.. μ΄ νλ λ¬Έμ μ μ΄ μμ΅λλ€.
- μμλ₯Ό ν 90κ° λ£κ³ κ·Έ μμλ₯Ό 90κ° λ€μ§μ°λ©΄? Frontμ Rearκ° κ°κ° 89λ₯Ό κ°λ¦¬ν€κ² λκ² μ§μ? κ·ΈλΌ λ¨λ 곡κ°μ 10-_-κ°λ°μ μλ©λλ€.
- μ΄λ κ² λλ©΄ 첨μ 100κ°μ λ°°μ΄μ ν λΉν΄μ€κ²μ€μ 90κ°λ₯Ό λͺ» μ°κ² λκ² λ€μ.
- μ΄λ₯Ό 보μνκΈ° μν΄ μν νλΌλκ² μλλλλ€. λλ λ§ν¬λ 리μ€νΈλ‘ νλ₯Ό λ§λ€μ΄μ μ νμμ΄ μ°λ λ°©λ²λ μκ² μ£ .
- μκ²λ λ§λ€μ΄λ΄μΌκ² μ£ ?^^