| 
 | 
 
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册 
 
 
 
×
 
// A  quene class for characters. 
class Quene{ 
 private char q[];//this array holds the quene 
 private int publoc,getloc; //the put and get indices. 
 
 // Construct an empty Quene given its size. 
Quene(int size){ 
q=new char[size+1];                      //? 
putloc=getloc=0; 
                     } 
 
// Construct  a Quene from a Quene. 
 
 
Quene (Quene ob){ 
putloc=ob.putloc; 
getloc=ob.getloc; 
q=new char[ob.q.length]; 
//copy elements 
for(int i=getloc+1;i<=putloc;i++)            //? 
q=ob.q; 
                } 
 Quene (char a[]){ 
 putloc=getloc=0; 
q=new char [a.length+1]; 
for(int i=0;i<a.length;a++) 
put a; 
                      } 
// put a character into the quene.  
void put(char ch){ 
 if(putloc==getloc){ 
 System.out.println("Quene is full"); 
 return; 
                             } 
  putloc++; 
 q[putloc]=ch; 
                          } 
 //get a character from the quene. 
char get[]{ 
if(getloc==putloc){ 
 System.out.println("Quene is empty.") 
 return (char)0; 
                           } 
getloc++; 
return q[getloc]; 
                 } 
 
   
                        } 
 
该程序想设计出一个先入先出的队列。这只是程序的一部分。但是我有的地方不太明白(打问号的行),请各位帮忙解释一下。 |   
 
 
 
 |