#include <iostream>
using namespace std
template<class Telem>
class SqQueue{
Telem *elem
int front,rear,count
const int len
public:
SqQueue(int maxsz=12):len(maxsz){
elem=new Telem[len]
front=rear=count=0
}
~SqQueue(){delete []elem}
void clear(){rear=front=count=0}
int leng(){return count}
bool empt(){return (count==0)}
bool full(){return (count>=len)}
bool enque(Telem &el)
Telem dlque()
Telem getf()
}
template <class Telem>
bool SqQueue<Telem>::enque(Telem &el){
if(count>=len) return false
else{
elem[rear]=el
rear=(rear+1)%len
count++
return true
}
}
template<class Telem>
Telem SqQueue<Telem>::dlque(){
if(count==0) return NULL
else{
Telem el=elem[front]
front=(front+1)%len
count--
return el
}
}
template <class Telem>
Telem SqQueue<Telem>::getf(){
if(count==0) return NULL
else{
Telem el=elem[front]
return el
}
}
void main(){
SqQueue<int>sq
int a=10
int b=20
int c=30
int d=40
int e=50
int f=60
int g=70
int h=80
int i=90
cout<<sq.enque(a)<<endl
cout<<sq.enque(b)<<endl
cout<<sq.enque(c)<<endl
cout<<sq.enque(d)<<endl
cout<<sq.enque(e)<<endl
cout<<sq.enque(f)<<endl
cout<<sq.enque(g)<<endl
cout<<sq.enque(h)<<endl
cout<<sq.enque(i)<<endl
cout<<sq.leng()<<endl
cout<<sq.dlque()<<endl
cout<<sq.leng()<<endl
cout<<sq.getf()<<endl
}
//顺序队列实现元素入队列和出队列#include<stdio.h>
#define M 10
typedef struct Node//顺序队列的声明!
{
int data[M]
int front
int rear
}SeqQueue
void InitSeqQueue(SeqQueue&L) //初始化队列!
{
L.rear=L.front=0
printf("顺序队列初始化成功!\n")
}
int EnSeqQueue(SeqQueue&L,int e)//入队列 *** 作!
{
if(L.rear==(M-1))
{
printf("队列已满,无法进行插入 *** 作!\n")
return 0
}
L.data[L.rear++]=e
printf("入队成功!\n")
return 1
}
int DeSeqQueue(SeqQueue&L) //出队列 *** 作!
{
if(L.front==L.rear)
{
printf("队列为空,无法进行出队列 *** 作!\n")
return 0
}
return L.data[L.front++]
}
void main()
{
SeqQueue L
int e,i
InitSeqQueue(L)
printf("请输入要入队的5个元素:\n")
for(i=0i<5i++)
{
scanf("%d",&e)
EnSeqQueue(L,e)
}
DeSeqQueue(L)
}
少先队入队仪式的程序如下:
1、全体立正。
2、出旗。(奏队歌,全体队员敬礼)。
3、唱队歌 。(全体少先队员齐唱)。
4、宣布新队员名单。
5、授予队员标志。(授予者双手托红领巾授予新队员。新队员双手接过,放在颈上,授予者给新队员打上领结,接着互相敬礼)。
6、宣誓。(由仪式主持人领读,读誓词时举右手)。
7、老队员代表讲话。
8、新队员代表讲话。
9、大队辅导员讲话。
10、退旗。(奏队歌,全体队员敬礼)。
11、仪式结束。
入队意义:
少先队在少年儿童的教育中起着一种特殊的,不可替代的作用,少先队组织是学校教育的得力助手,它配合学校引导少年儿童树立远大的革命理想;培养他们的集体主义精神和主动性、积极性、创造性;促进广大少年儿童在德、智、体、美、劳诸方面都得到发展。
少先队教育不同于学校教育,少先队的主要教育手段是活动,寓教育于活动之中。少先队通过它独特的教育方法,配合学校做好少年儿童工作,把他们培养成为有理想、有道德、有文化、有纪律的共产主义事业的接班人。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)