ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1220. Stacks

Please help me ! Why I got Compilation Error in C++ ?
Posted by Cold Weather 21 Jul 2005 20:28
Here my code :
#include <stdio.h>
#include <conio.h>

long pt,i,n ;
int x ;
int tt , stack ,L[1000] , B[100000] ;
long A[100000] ;
char s[4]  ;

void main()
{

 scanf("%ld",&n) ;

 pt = 0 ;

 for ( i=1 ; i <= n ; i++ )
 {
   scanf("%s",&s);
   if ( s[0] == 'P' && s[1] == 'O' )
     {
       scanf("%ld",&A[i]) ;
       A[i] = - A[i] ;
     }
   else
     {
       scanf("%d%ld",&x,&A[i]) ;
       pt   += 1 ;
       B[pt] = x ;
     }
 }
 for ( i=1 ; i <= 1000 ; i++ ) L[i] = 0 ;
 for ( i=n ; i > 0 ; i-- )
 {
   if ( A[i] > 0 )
     {
       stack = B[pt] ;
       pt -= 1 ;
       if ( L[stack] > 0 )
        {
          tt = L[stack]    ;
          L[stack] = A[tt] ;
          A[tt] = A[i]     ;
        }
       A[i] = -1 ;
     }
   else
    {
      stack = - A[i]  ;
      A[i] = L[stack] ;
      L[stack] = i    ;
    }
 }
 for ( i=1 ; i <= n ; i++ ) if ( A[i] >= 0 ) printf("%ld \n",A[i]) ;
}
Don't use <conio.h> (-)
Posted by Victor Barinov (TNU) 21 Jul 2005 22:52
Re: Don't use <conio.h> (-)
Posted by Cold Weather 22 Jul 2005 06:50
Thank you very much !