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

why i got compilation error ( code included ) please help me
Posted by Hany 4 Sep 2003 00:45
#include<stdio.h>
#include<iostream.h>
#include<string>
using namespace std;

struct st
{
 int name;
 string num;
};

main()
 {
  int n;
  cin>>n;
  st *arr=new st[n];
  string *arr2=new string[(n/2)+1];
  string temp;
  int temp2;
  int count=0;
  int count2=0;
  for(int i=0;i<n;i++)
  {
   cin>>temp;
   if(temp=="PUSH")
    {
     cin>>arr[count].name;
     cin>>arr[count].num;
     count++;
    }
   else
   if(temp=="POP")
    {
      cin>>temp2;
      for(int j=count-1;j>=0;j--)
       {
        if(arr[j].name==temp2)
         {
          arr2[count2]=arr[j].num;
          arr[j].name=-1;
          count2++;
          break;
         }
       }
    }
  }
  for(int i=0;i<count2;i++)
   cout<<arr2[i]<<endl;
}