sdut 3346 sdut 3344 Runtime Error Runtime Error?

2024-03-04 03:38
文章标签 error runtime sdut 3344 3346

本文主要是介绍sdut 3346 sdut 3344 Runtime Error Runtime Error?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

数据结构实验之二叉树七:叶子问题

Time Limit: 1000MS  Memory Limit: 65536KB
Submit  Statistic  Discuss
Problem Description

已知一个按先序输入的字符序列,如abd,,eg,,,cf,,,(其中,表示空结点)。请建立该二叉树并按从上到下从左到右的顺序输出该二叉树的所有叶子结点。

Input
输入数据有多行,每一行是一个长度小于 50 个字符的字符串。
Output
按从上到下从左到右的顺序输出二叉树的叶子结点。
Example Input
abd,,eg,,,cf,,,
xnl,,i,,u,,
Example Output
dfg
uli
#include <iostream>
#include <string.h>
#include <queue>
#include <stack>
#include <malloc.h>
using namespace std;
typedef struct btree
{char data;btree *lchild,*rchild;
}btree;
int i;
char ch[100];
btree *root;
btree * createbtree(btree *&root)
{char c;c=ch[i++];if(c==',')root=NULL;else{root=(btree *)malloc(sizeof(btree));root->data=c;root->lchild=createbtree(root->lchild);root->rchild=createbtree(root->rchild);}return root;
}
void levelorder()
{btree *b=root;queue<btree*>Queue;Queue.push(b);while(!Queue.empty()){b=Queue.front();Queue.pop();//这个没有返回值if(b->lchild==NULL&&b->rchild==NULL)cout<<b->data;if(b->lchild!=NULL)Queue.push(b->lchild);if(b->rchild!=NULL)Queue.push(b->rchild);}cout<<endl;
}
int main()
{while(cin>>ch){i=0;root=createbtree(root);levelorder();}return 0;
}

数据结构实验之二叉树五:层序遍历

Time Limit: 1000MS  Memory Limit: 65536KB
Submit  Statistic  Discuss
Problem Description

已知一个按先序输入的字符序列,如abd,,eg,,,cf,,,(其中,表示空结点)。请建立二叉树并求二叉树的层次遍历序列。

Input
输入数据有多行,第一行是一个整数t (t<1000),代表有t行测试数据。每行是 一个长度小于50个字符的字符串。
Output
输出二叉树的层次遍历序列。
Example Input
2
abd,,eg,,,cf,,,
xnl,,i,,u,,
Example Output
abcdefg
xnuli
#include <iostream>
#include <queue>
#include <malloc.h>
using namespace std;
typedef struct btree
{char data;btree *lchild,*rchild;
}btree;
char ch[55];
int i;
void createbtree(btree *&root)
{char c=ch[i++];if(c==',')root=NULL;else//按先序建立二叉树,要是按照中序后序的顺序自己应该会会写出{root=(btree *)malloc(sizeof(btree));root->data=c;createbtree(root->lchild);createbtree(root->rchild);}
}
void levelorder(btree *&root)
{queue<btree*>Queue;btree *p=root;Queue.push(root);while(!Queue.empty()){p=Queue.front();cout<<p->data;Queue.pop();if(p->lchild!=NULL)Queue.push(p->lchild);if(p->rchild!=NULL)Queue.push(p->rchild);}
}
int main()
{int n;while(cin>>n){while(n--){i=0;cin>>ch;btree *root;root=(btree*)malloc(sizeof(btree));createbtree(root);levelorder(root);cout<<endl;}}return 0;
}/***************************************************
User name: YT1658506207邵雪源
Result: Runtime Error
Take time: 0ms
Take Memory: 0KB
Submit time: 2017-11-06 18:31:30
****************************************************/


这篇关于sdut 3346 sdut 3344 Runtime Error Runtime Error?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/771894

相关文章

Golang进程权限调度包runtime

关于 runtime 包几个方法: Gosched:让当前线程让出 cpu 以让其它线程运行,它不会挂起当前线程,因此当前线程未来会继续执行GOMAXPROCS:设置最大的可同时使用的 CPU 核数Goexit:退出当前 goroutine(但是defer语句会照常执行)NumGoroutine:返回正在执行和排队的任务总数GOOS:目标操作系统NumCPU:返回当前系统的 CPU 核数量 p

编译linux内核出现 arm-eabi-gcc: error: : No such file or directory

external/e2fsprogs/lib/ext2fs/tdb.c:673:29: warning: comparison between : In function 'max2165_set_params': -。。。。。。。。。。。。。。。。。。 。。。。。。。。。。。。。 。。。。。。。。 host asm: libdvm <= dalvik/vm/mterp/out/Inte

收藏:解决 pip install 出现 error: subprocess-exited-with-error 错误的方法

在使用 pip 安装 Python 包时,有时候会遇到 error: subprocess-exited-with-error 错误。这种错误通常是由于 setuptools 版本问题引起的。本文将介绍如何解决这一问题 当你使用 pip install 安装某个 Python 包时,如果 setuptools 版本过高或过低,可能会导致安装过程出错,并出现类似以下错误信息:error: subpr

Nn criterions don’t compute the gradient w.r.t. targets error「pytorch」 (debug笔记)

Nn criterions don’t compute the gradient w.r.t. targets error「pytorch」 ##一、 缘由及解决方法 把这个pytorch-ddpg|github搬到jupyter notebook上运行时,出现错误Nn criterions don’t compute the gradient w.r.t. targets error。注:我用

src/pyaudio/device_api.c:9:10: fatal error: portaudio.h: 没有那个文件或目录

(venv) shgbitai@shgbitai-C9X299-PGF:~/pythonworkspace/ai-accompany$ pip install pyaudio sounddeviceCollecting pyaudioDownloading PyAudio-0.2.14.tar.gz (47 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ERROR 2003 (HY000): Can't connect to MySQL server on (10061)

在linux系统上装了一个mysql-5.5,启动后本机都是可以访问的,操作都正常,同时建了一个%的用户(支持远程访问), root@debian:/# mysql -u loongson -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id

pip install pyaudio sounddevice error: externally-managed-environment

shgbitai@shgbitai-C9X299-PGF:~/pythonworkspace/ai-accompany$ pip install pyaudio sounddeviceerror: externally-managed-environment× This environment is externally managed╰─> To install Python package

C++常见异常汇总(三): fatal error: google/protobuf/port_def.inc

文章目录 1、fatal error : sw/redis++/redis.h2、fatal error: dwarf.h: No such file or directory3、fatal error: elfutils/libdw.h: No such file or directory4、fatal error: libunwind.h: No such file or directo

error while loading shared libraries: libnuma.so.1: cannot open shared object file:

腾讯云CentOS,安装Mysql时: 1.yum remove libnuma.so.1 2.yum install numactl.x86_64

【NodeJS】Error: Cannot find module 'ms'

转载自:http://blog.csdn.net/echo_ae/article/details/75097004 问题: Error: Cannot find module 'ms'at Function.Module._resolveFilename (module.js:469:15)at Function.Module._load (module.js:417:25)at Module