包含头文件 #include <ctime>int t1, t2;程序开始计算前: t1 = clock(); 程序计算结束后: t2 = clock();那么t2 - t1 就是计算所需的时间了,单位就是ms