Generation

generate functionWed, 19 Jul 2023

把一个栈里的数放到一个队列里,数值从小到大

++ int i = 0; int a[100000]; int queue[100000]; int stack[100000]; int pointer; void push(int value) { stack[pointer++] = value; } void pop() { int temp = stack[--pointer]; queue[i++] = temp; return temp; } void main(int n) { int temp = n; while (temp != 0) { push(temp); temp--; } while (pointer != 0) { pop(); } for (int j = 0; j < i - 1; j++) { if (queue[j] > queue[j + 1]) { cout << "false"; return; } } cout << "true"; }

Want to kickstart your project?Use the new AI Studio to create your code