|
|
back to boardCrash(acsses violation) on 3test why??? #include <iostream> //#include <stdlib.h> //#include <stdio.h> #include <string.h> using namespace std; int i,o,tp,nm; struct Tpart { int val [24]; int k; Tpart *lst;
}; char com[100]; Tpart stk[1024]; int Pop(Tpart *p) { if(p->k>0) return p->val[--(p->k)]; else { Tpart *e=p; p=p->lst; delete e; return p->val[--(p->k)]; }}; void Push(Tpart *p, int val) { if((p->k)<24) (p->val)[(p->k)++]=val; else { Tpart *uk= new Tpart; uk->lst=p; p=uk; p->k=0; (p->val)[(p->k)++]=val; } return; } int main() { int n; cin>>n; for(int j=0;j<n;j++) { cin>>com; if (strcmp(com,"PUSH")==0) { cin>>nm>>tp; Push(&stk[nm-1],tp); } if (strcmp(com,"POP")==0) { cin>>nm; cout<<Pop(&stk[nm-1])<<endl;} } return 0; } Re: Crash(acsses violation) on 3test I've this problem too(( |
|
|