查程序的空间时间

查时间

#include <ctime>
...
int main() {
	int st=clock();
	n=read();
	...	
	int ed=clock();
	cout<<(double)(ed-st)/CLOCKS_PER_SEC;
	return 0;
}

空间

在linux 下命令板直接调用

\(size\) 函数 —— size + 可执行文件名

windows 下

bool f1;
int a[108348];
bool f2;
int main() {
	cout<<(&f2-&f1)/1024.0/1024<<"MB";
	return 0;
}

注意\(f1\)\(f2\)之间不要有递归

posted @ 2020-12-03 08:23  ke_xin  阅读(110)  评论(0编辑  收藏  举报