Skip to content

Commit

Permalink
queue.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Louffy committed Dec 14, 2011
1 parent c3c2c92 commit 3f561d8
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 25 deletions.
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
*
!*.c
!*.cpp
!*.sh
!README
!.gitignore
!makefile
*.[oa]
*~
.*.c.swp
资料/

*.[zip|tar]
7 changes: 7 additions & 0 deletions c++/mymakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
queue:queue.o
g++ -o queue queue.o
queue.o:queue.cpp
g++ -c -g -Wall queue.cpp
clean:
rm *.o

Binary file added c++/queue/a.out
Binary file not shown.
7 changes: 7 additions & 0 deletions c++/queue/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
queue:queue.o
g++ -o queue queue.o
queue.o:queue.cpp
g++ -c -g -Wall queue.cpp
clean:
rm *.o

Binary file modified c++/queue/queue
100644 → 100755
Binary file not shown.
39 changes: 23 additions & 16 deletions c++/queue/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,26 @@ class QUEUE
};
NODE *front,*rear;
public:
QUEUE();
QUEUE()
{
front=rear=NULL;
cout<<"queue()\n";
}
~QUEUE();
int insert(char v);
int remove(char &v);
int empty();
//int destroy();
};
QUEUE::NODE::NODE(char v)
{
elem=v;
next=0;
}
QUEUE::QUEUE()
{
front=rear=0;
next=NULL;
}


QUEUE::~QUEUE()
{
NODE *p;
NODE *p=NULL;
while(front)
{
p=front->next;
Expand All @@ -40,13 +41,19 @@ QUEUE::~QUEUE()
int QUEUE::insert(char v)
{
NODE *p=new NODE(v);
if(p==0)return 0;
rear->next=p;
p->next=0;
if(p==NULL)return 0;
if(front==NULL){
front=p;
}
else{
rear->next=p;

}
rear=p;
printf("%c\n",p->elem);
//cout<<v;
return 1;
}

int QUEUE::remove(char &c)
{
NODE *p=front;
Expand All @@ -57,16 +64,16 @@ int QUEUE::remove(char &c)
}
int QUEUE::empty()
{
if(front==rear==0)return 1;
if(front==NULL&&rear==NULL)return 1;
else return 0;
}

int main(void)
{
QUEUE q;
int v;
q.insert(5);
q.insert(6);
char v;
q.insert('a');
q.insert('b');

}

Expand Down
6 changes: 5 additions & 1 deletion shell/b2d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ error()
echo "$1"
exit 1
}

while [ -n "$1" ] ;do
case $1 in
-h)help;shift $1;;#shift 是去除$1,把$2变成$1
esac
done
#

17 changes: 17 additions & 0 deletions shell/nso
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
zhang love
xue
fei 3
xue
zhang love
is
a
good
people
8
3
9
4
2
0
7
8
20 changes: 20 additions & 0 deletions shell/so
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
zhang love
zhang love
zhang love
xue
fei 3
xue
zhang love
is
is
a
good
people
8
3
9
4
2
0
7
8

0 comments on commit 3f561d8

Please sign in to comment.