C++ stream

由一道二叉树题引入:UVA548

https://www.luogu.com.cn/problem/UVA548

 

 

这道题其实别的都不难
深搜建树
再深搜一次找最小
 
 
 
放一下之前代码
bool put_in(char r[])
{
    if(cin>>e)
    {
        int cnt=1;
        while(cin>>r[cnt])!='\n') cnt++;
        r[cnt]='\0';
        return 1;
    }
    else return 0;
}

int buildtree(string s1,string s2)
{
   
}

void dfs(int sum ,int head)
{
   
}

int main()
{
    while(put_in(st1))
    {
        put_in(st2);
        head1=buildtree(st1,st2);
        dfs(0,head1);
        cout<<best<<endl;
    }
    return 0;
}

 

 
仔细看题
输入方式确实不能用传统的,首先一定得用getline,因此末尾补\0行不通,必须用流的转化
 
 
 
所以这篇文章其实想要说说——
 
 
 
posted @ 2020-03-16 22:13  juuich  阅读(59)  评论(0)    收藏  举报