Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

请各位帮忙看下,我这个为什么是RE

Posted by 604567212 at 2011-08-16 15:39:09 on Problem 1785
#include<iostream>
#include<stdio.h>
using namespace std;

struct node
{
 node*fa;
 char a[500];
 long long b;
 node*l,*r;
};

void dfs(node*n)
{
  if(n==NULL)
  return;
  printf("(");
  dfs(n->l);
  printf("%s/%I64d",n->a,n->b);
  dfs(n->r);
  printf(")");
  return;
}  
     
int main()
{
   int n;
   while(scanf("%d",&n)&&n)
   {
     node*temp=new node;
     temp=NULL;
     node*begin=new node;
     begin->b=0;
     for(int i=0;i<n;i++)
     {
       node*t=new node;
       int in=0;
       getchar();
       while(scanf("%c",&t->a[in])&&t->a[in]!='/')
        in++; 
       t->a[in]=0;
       scanf("%I64d",&t->b);
       t->fa=NULL;
       t->l=NULL;
       t->r=NULL;
       if(begin->b<t->b)
       begin=t;
       if(temp!=NULL)
       {
        while(temp->b<t->b&&temp->fa!=NULL)
        temp=temp->fa;
        if(temp->b>t->b)
          {
           temp->r=t;
           t->fa=temp;
          }
        else
         {
          t->l=temp;
          temp->fa=t;
         } 
       }
      temp=t;
     }
     dfs(begin); 
     printf("\n");
   }         
   return 0;
}      

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator