[Codevs Cup Road] P3143

Source: Internet
Author: User

How do you get the AC without charging?

Title: http://codevs.cn/problem/3143/

A flood problem, as long as it will traverse, here to talk about ideas

First Order traversal: first output, then left son, last right son

Middle sequence traversal: first left son, then output, last right son

Post-post traversal: first left son, then right son, final output

1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <cmath>5#include <iostream>6#include <algorithm>7 #defineN 208 using namespacestd;9 Ten intL[n],r[n],n; One voidQianintx) A { -     if(x==0)return; -printf"%d", x); the Qian (l[x]); - Qian (r[x]); - } - voidZhongintx) + { -     if(x==0)return; + Zhong (l[x]); Aprintf"%d", x); at Zhong (r[x]); - } - voidHouintx) - { -     if(x==0)return; - Hou (l[x]); in Hou (r[x]); -printf"%d", x); to } + intMain () - { the     inti; *scanf"%d",&n); $      for(i=1; i<=n;i++) scanf ("%d%d",&l[i],&r[i]);Panax NotoginsengQian1); -printf"\ n"); theZhong1); +printf"\ n"); AHou1); theprintf"\ n"); +     return 0; -}

[Codevs Cup Road] P3143

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.