acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • 求救!!!

    #include<iostream> using namespace std; const int Maxlen = 501; struct queue{ int q[Maxlen]; int head,tail; void push(int x){ q[tail]=x; tail = (tail+1)%Maxlen; } void pop(){ head = (head+1)%Maxlen; } bool empty(){ return headtail; } bool full(){ return (tail+1)%Maxlenhead; } int length(){ return (tail+Maxlen-head)%Maxlen; } int front(){ return q[head]; } void init(){ head = tail = 0; } }; int main(){ queue a; a.init(); int n,k; cin >> n >> k; for (int i = 0; i < n;i++){ int linshi; cin >> linshi; a.push(linshi); } bool flag = 1,win = 0; int tmp = a.front(); a.pop(); while(k != win){ if (a.front() < tmp){ win++; a.push(a.front()); a.pop(); }else{ win = 0; a.push(tmp); tmp = a.front(); a.pop(); } } cout << tmp; return 0; }

    userId_undefined

    赵梓涵

    倔强青铜
    11阅读
    0回复
    0点赞
首页