摘要: // 求最大子列和 #include <cstdio> int a[5]; // O(n^3) int MaxSeq1(int a[], int n) { int max = 0, sum = 0; for(int i = 0; i < n; ++ i) { for(int j = i; j < n; ++ j) { sum = 0; for(int k = i; k <= j; ++ k) { 阅读全文
posted @ 2019-08-27 19:20 青衫客36 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2019-08-27 17:49 青衫客36 阅读(90) 评论(0) 推荐(0) 编辑
摘要: /* 计时程序 */ #include #include clock_t start, stop; /* clock_t 是clock()函数返回的变量类型 */ double duration; /* 记录被测函数运行时间, 以秒为单位 */ int main() { /* 不在测试范围内的准备工作写在clock()调用之前 */ start = clock(); // 开始计时... 阅读全文
posted @ 2019-08-27 17:30 青衫客36 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 例二: 多项式 运行时间不到一个tick, 那怎么才能显示出一个tick所用的时间呢?(即如何测出不到1个tick的程序运行时间?) 让被测函数重复运行多次, 使得测出的总的时钟打点数间隔充分长, 最后计算出被测函数平均每次运行的时间即可 阅读全文
posted @ 2019-08-27 17:27 青衫客36 阅读(325) 评论(0) 推荐(0) 编辑