Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
const UCHAR N = 3, Q_EMPTY = 2, Q_FULL = 1; struct queue { UCHAR begin = 0, end = 0; LONGLONG data[N] = { 0 }; }; UCHAR push(queue &q, LONGLONG elem); UCHAR pop(queue &q, LONGLONG &elem); bool is_empty(queue q); bool is_full(queue q); void clear(queue &q); void print(queue q); int main() { queue Q; return 0 * _getch(); } UCHAR push(queue &q, LONGLONG elem) { bool is_f = is_pfull(q); if (!is_f) { q.end++; q.data[q.end] = elem; } return is_f ? Q_FULL : 0; } UCHAR pop(queue &q, LONGLONG &elem) { bool is_e = is_empty(q); if (!is_e) { elem = q.data[q.begin]; q.data[q.begin] = 0; q.begin++; } return is_e ? Q_EMPTY : 0; } bool is_empty(queue q) { return q.end == q.begin; } bool is_full(queue q) { return q.end == N -1 && q.begin == 0; } bool is_pfull(queue q) { return q.end == N - 1 && q.begin; } void clear(queue &q) { for (LONGLONG n = 0; !is_empty(q); pop(q, n)); } void print(queue q) { LONGLONG n = 0; while (!is_empty(q)) { pop(q, n); printf_s("%lld", n); } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)