当前位置:网站首页>C # implements queue structure definition, incoming and outgoing operations
C # implements queue structure definition, incoming and outgoing operations
2022-06-29 12:53:00 【Dusk and starry sky】
In this paper, C# Implement queue structure definition 、 The team 、 Out of line operation
1、 Queue structure definition
///
/// Queue structure definition
///
public struct SqQueue {
public int[] data;// Queued elements
public int front, real;// Team leader and team leader
}
2、 Queue initialization
///
/// Queue initialization
///
///
static void InitQueue(ref SqQueue Q) {
Q.real = Q.front=0;
}
3、 Determines if the queue is empty
///
/// Determines if the queue is empty
///
///
///
static bool isEmpty( SqQueue Q) {
if (Q.front == Q.real) { return true; }
else return false;
}
4、 The team
///
/// The team
///
///
///
///
static bool EnQueue(ref SqQueue Q,int x) {
if ((Q.real+1)%MAXSizeQ.front) { return false; }
Q.data[Q.real] = x;
Q.real = (Q.real + 1) % MAXSize;
return true;
}
5、 Out of the team
static bool DeQueue(ref SqQueue Q, ref int x) {
if (Q.realQ.front) { return false; }
x = Q.data[Q.front];
Q.front = (Q.front + 1) % MAXSize;
return true;
}
6、 actual main Function test
static void Main(string[] args)
{
SqQueue Q = new SqQueue();
Q.data = new int[MAXSize];
int x = 0;
// Initialize queue
InitQueue(ref Q);
while (x!=999) {
Console.WriteLine(“ Please enter the team entry element :”);
x = int.Parse(Console.ReadLine());
if ((Q.real+1)%MAXSize==Q.front) {
Console.WriteLine(“ The queue is full .”);
break;
}
if (x!=999) EnQueue(ref Q, x);
}
// Out of the team
Console.WriteLine(“ The output elements are as follows :”);
while (!isEmpty(Q)) {
DeQueue(ref Q,ref x);
Console.WriteLine(x);
}
Console.ReadLine();
}
边栏推荐
- How to create new user for ORACLE 19c (CDB & PDB)
- Problem solving: modulenotfounderror: no module named 'pip‘
- Kyligence Zen, an intelligent indicator driven management and decision-making platform, is newly launched and is in limited internal testing
- Comment calculer Win / Tai / Loss in paired t - test
- Gbase8s database select has a having clause
- 倍福TwinCAT3 的OPC_UA通信测试案例
- Gbase8s database select has order by Clause 1
- 解决问题:ModuleNotFoundError: No module named ‘pip‘
- 求大数的阶乘 ← C语言
- MySQL 主从复制原理以及流程
猜你喜欢

揭秘百度智能测试在测试自动执行领域实践

Murphy safety was selected for signing 24 key projects of Zhongguancun Science City
![[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial](/img/00/9a6d17844b88f6921ad488f4975684.png)
[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial

如何计算win/tai/loss in paired t-test

推荐模型复现(一):熟悉Torch-RecHub框架与使用

How to install oracle19c in Centos8

百度云盘不限速下载大文件(2021-11亲测有效)

倍福控制器连接松下EtherCAT伺服注意事项

Go learning - build a development environment vscode development environment golang

Paper reproduction - ac-fpn:attention-guided context feature pyramid network for object detection
随机推荐
Understanding of P value
C#实现二叉排序树定义、插入、构造
Unexpected ‘debugger‘ statement no-debugger
Viewing splitchunks code segmentation from MPX resource construction optimization
C#通过线索二叉树进行中序遍历输出
Cocos star meetings at Hangzhou station in 2022
Gbase8s database into temp clause creates a temporary table to save query results.
Is it safe for Orient Fortune Securities to open an account? Handling of securities account opening
Go learning - build a development environment vscode development environment golang
Syntax of gbase8s database incompatible with for update clause
揭秘百度智能测试在测试自动执行领域实践
Inferiority complex and transcendence the meaning of life to you
在印度与软件相关的发明可不可以申请专利?
File contained log poisoning (user agent)
Gbase8s database select has order by Clause 6
qt 自定义控件 :取值范围
Gbase8s database into external clause
二十三、1-Bit数据的存储(延迟线/磁芯/DRAM/SRAM/磁带/磁盘/光盘/Flash SSD)
Huffman coding
Recommended model recurrence (I): familiar with torch rechub framework and use