root站长大大,为啥错了

tctm135 2024-01-07 18:12:33 2024-01-07 18:12:46 17

#include <bits/stdc++.h> using namespace std; char a[225]; int top = 0; int id=0; void push(int x) { top++; a[top] = x; return; } void pop() { top--; return; } int gettop() { int t = a[top]; return t; } void clear() { top = 0; return; } int main() { int n; int b[1001]; cin>>n; for(int i=1;i<=n;i++){ cin>>b[i]; } int j=1; int mx; push(1); for(int i=1;i<=n;i++){ mx=max(mx,top); if(b[i]>gettop()){ while(b[i]<=gettop()){ push(j); j++; } } else if(b[i]==gettop()){ pop(); } else if(b[i]<1){ cout<<"no"; return 0; } } if(top==0){ cout<<"yes"<<endl; cout<<mx; } else{ cout<<"no"; } return 0; }

{{ vote && vote.total.up }}

共 1 条回复

root 站长

cin >> n 放到 freopen 后面试试