#include
using namespace std;
int n, a[10000], l = 5000, r = 5000;
void make_tree(int now)
{
int x;
cin >> x;
if(x == -1)
return;
a[now] += x;
l = min(l, now);
r = max(r, now);
make_tree(now - 1);
make_tree(now + 1);
}
int main ()
{
make_tree(5000);
for (int i = l; i <= r; ++i)
cout << a[i] << " ";
}
求助这串C++代码怎么改成python啊
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- threenewbee 2019-01-22 23:54关注
n=0 a=[0]*[10000] l = [0]*5000 r = [0]*5000 def make_tree(now): x = int(input()) if(x == -1): return a[now] = a[now] + x l = min(l, now) r = max(r, now) make_tree(now - 1) make_tree(now + 1) def main(): make_tree(5000) for (i in range(r)): print(a[i])
解决 无用评论 打赏 举报
悬赏问题
- ¥20 随身WiFi移动网络访问不了
- ¥50 RAD_XE11.3获取android11手机的IMEI码
- ¥15 linux的gcc命令报错
- ¥20 如何再GIS用海岸线建立缓冲区
- ¥15 codeblock遇到问题了,求帮助😭
- ¥15 Qt6.8.0加载网页MSVC2022
- ¥15 360浏览器m2的这个值
- ¥15 国内有哪些厂商做automlops的?
- ¥15 skynet pb mysql
- ¥15 笔记本外接显示器分辨率太低各种方法都用过了调不高