/************************************************************************* > File Name: p.cpp > Author: Zcy > Mail: [email protected] > Created Time: 三 1/23 18:16:17 2019 ************************************************************************/
#include <stdio.h> #include <stdlib.h> using namespace std;
template <typename type> class Que{ private: type *data; int head, tail; public: Que() { head = 0; tail = -1; data = (type *)malloc(sizeof(type) * 105); } ~Que() { free(this -> data); } void add(type data) { tail++; this -> data[tail] = data; return; } void pop() { if (!empty()) { head++; } return; } bool empty() { return head > tail; } void output() { for (int i = head; i <= tail; i++) { printf("%d%c", data[i], i == tail? 'n': ' '); } return; } int gethead() { return head; } int gettail() { return tail; } };
int main () { int n, m, val; Que<int> que; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &val); que.add(val); } scanf("%d", &m); for (int i = 1; i <= m; i++) { que.pop(); } que.output(); return 0; }
|
近期评论