Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请各位帮忙看下,我这个为什么是RE#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator